Question

Hey, I have some trouble using the stream_publish method, more exactly with the attachment I want to include. I am building a desktop application and I want to be able to post on a user's wall. The post will include a message and a photo I will upload from my local HDD. The problem is I don't know how to specify the source attribute of the attachment. Here is a code snippet:

Attachment attachment = new Attachment();
AttachmentMedia media = new AttachmentMediaImage("file:/c:/picture.png", "file:/c:/picture.png");
attachment.addMedia(media);
facebook.stream_publish("picture", attachment, null, new Long(xxxxxxxL), null);

I simply can't figure out how to construct the AttachmentMediaImage object. I keep getting the following exception:

com.google.code.facebookapi.FacebookException: One or more of your image records failed to include a valid 'href' field.
    at com.google.code.facebookapi.JsonHelper.parseCallResult(JsonHelper.java:59)
    at com.google.code.facebookapi.ExtensibleClient.extractString(ExtensibleClient.java:2296)
    at com.google.code.facebookapi.ExtensibleClient.stream_publish(ExtensibleClient.java:2150)
    at com.google.code.facebookapi.SpecificReturnTypeAdapter.stream_publish(SpecificReturnTypeAdapter.java:503)
    at MainWindow$1.titleChange(MainWindow.java:64)
    at org.jdesktop.jdic.browser.WebBrowser.dispatchWebBrowserEvent(Unknown Source)
    at org.jdesktop.jdic.browser.NativeEventThread$2.run(Unknown Source)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

Any help will be appreciated. Thanks!

Was it helpful?

Solution

When creating the AttachmentMediaImage you need to use a URL of an image on a public webserver - you can't upload a local image using this API.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top