Note that there are some explanatory texts on larger screens.

plurals
  1. POPosting to Facebook feed from Android app
    primarykey
    data
    text
    <p>I am trying to enable users who have linked their Facebook account to be able to post to their wall with one button press as <a href="http://developers.facebook.com/docs/reference/api/post" rel="nofollow noreferrer">detailed in their docs</a>. Specifically, I do not want to use the .dialog methods provided in the <a href="http://github.com/facebook/facebook-android-sdk" rel="nofollow noreferrer">Facebook for Android library</a>, as I want the Publish process to be as seamless as possible.</p> <p>The specific call looks like this in an HTTP client simulator:<br> HTTP POST<br> <a href="https://graph.facebook.com/me/feed" rel="nofollow noreferrer">https://graph.facebook.com/me/feed</a><br> Content-type: application/x-www-form-urlencoded<br> access_token=...&amp;link=<a href="http://mylink.com/id/1326&amp;name=What" rel="nofollow noreferrer">http://mylink.com/id/1326&amp;name=What</a> do you think?&amp;description=Description of the link </p> <p>This call runs successfully in HTTP Client on OS X.</p> <p>I originally tried using the Facebook for Android library's .dialog function with "stream.publish" action, but this causes the unwanted dialog to appear.</p> <p>Next, I tried using Facebook for Android's .request function with "POST" parameter, but this function assumes that the body is a byte array and fails in multiple places in the library.</p> <p>Now, I am trying to use the Apache HTTP stack included with Android. Specifically, my code looks like this:</p> <pre><code>String url = "https://graph.facebook.com/me/feed"; ArrayList&lt;NameValuePair&gt; pairs = new ArrayList&lt;NameValuePair&gt;(4); pairs.add(new BasicNameValuePair("access_token", App.facebook.getAccessToken())); pairs.add(new BasicNameValuePair("link", "http://mylink.com/id/"+id)); pairs.add(new BasicNameValuePair("name", question)); pairs.add(new BasicNameValuePair("description", description)); InputStream inputStream = null; HttpResponse response = null; HttpClient client = null; try { final HttpPost post = new HttpPost(url); final UrlEncodedFormEntity entity = new UrlEncodedFormEntity(pairs); post.setEntity(entity); client = new DefaultHttpClient(); response = client.execute(post); } catch (IOException e) { // code to handle exceptions } // close streams, etc. </code></pre> <p>The problem is that the response from Facebook is consistently the following:</p> <pre><code>{"error":{"type":"OAuthException","message":"Invalid OAuth access token."}} </code></pre> <p>I know the OAuth access token is not invalid. When I paste the same OAuth access token into HTTP Client, it works like a champ. It seems that creating the HttpPost object's parameters is garbling the complex OAuth access token in some way. Does anyone have suggestions on how to proceed?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload