Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is one simple method to do this :</p> <pre><code>private void publishStory(String title, String youneed2, String youneed3) { Session session = Session.getActiveSession(); if (session != null){ // Check for publish permissions List&lt;String&gt; permissions = session.getPermissions(); if (!isSubsetOf(PERMISSIONS, permissions)) { pendingPublishReauthorization = true; Session.NewPermissionsRequest newPermissionsRequest = new Session .NewPermissionsRequest(getActivity(), PERMISSIONS); session.requestNewPublishPermissions(newPermissionsRequest); return; } Bundle postParams = new Bundle(); postParams.putString("name", title); postParams.putString("caption", "bla bla"); postParams.putString("description", "bla bla"); postParams.putString("link", "http://www.yoursite.com"); postParams.putString("picture", "http://linktoyourimage.com"); Request.Callback callback= new Request.Callback() { public void onCompleted(Response response) { JSONObject graphResponse = response .getGraphObject() .getInnerJSONObject(); String postId = null; try { postId = graphResponse.getString("id"); } catch (JSONException e) { Log.i(TAG, "JSON error "+ e.getMessage()); } FacebookRequestError error = response.getError(); if (error != null) { debug.print("erreur"); } } }; Request request = new Request(session, "me/feed", postParams, HttpMethod.POST, callback); RequestAsyncTask task = new RequestAsyncTask(request); task.execute(); } } </code></pre> <p>Don't forget that you need a valid Token, then call <code>PublishStory()</code> and build your post with the Bundle.</p> <p>Hope this help</p> <p><strong>Edit</strong></p> <p>Add these line before your onCreate()</p> <pre><code>private static final List&lt;String&gt; PERMISSIONS = Arrays.asList("publish_actions"); private static final String PENDING_PUBLISH_KEY = "pendingPublishReauthorization"; private boolean pendingPublishReauthorization = false; </code></pre>
    singulars
    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.
    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