Question

I'm using Android Facebook SDK 3.8. I'm trying to post a text on friend's wall. Even though there is no error(I'm getting the post-id), I cannot see the posting on my friend's wall. I tried WebDialog, facebook.dialog both, but no luck. All works fine when I'm posting something on to my wall.

Here's the code.

btnPostToWall.setOnClickListener(new View.OnClickListener() {

@SuppressLint("SimpleDateFormat")
@SuppressWarnings("deprecation")
@Override
public void onClick(View v) {

    try{
        mSession.requestNewPublishPermissions(new Session.NewPermissionsRequest(mActivity, "publish_actions", "publish_stream"));

        String fqlQuery = "SELECT uid,first_name,last_name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) ORDER BY last_name ASC";

        Bundle params = new Bundle();                               
        params.putString("format", "json");
        params.putString("q", fqlQuery);
        params.putString("access_token", mSession.getAccessToken());

        Request request = new Request(mSession, "/fql",
                params, HttpMethod.GET,
                new Request.Callback() {
                    public void onCompleted(
                            Response response) {

                        GraphObject go  = response.getGraphObject();
                        JSONObject  jso = go.getInnerJSONObject();

                            try {

                                JSONArray arr = jso.getJSONArray("data");

                                for ( int i = 0; i < ( arr.length() ); i++ )
                                {
                                    JSONObject json_obj = arr.getJSONObject( i );

                                    String name   = json_obj.getString("first_name");
                                    if(name.contains("Shivanka")){


                                        String uid   = json_obj.getString("uid");

                                        Facebook facebook=new Facebook("************");
                                        Bundle parameters = new Bundle();

                                        parameters.putString("to", uid);

                                        facebook.dialog(mActivity,"feed",parameters,new DialogListener() {

                                            @Override
                                            public void onComplete(Bundle values) {
                                                final String postId = values.getString("post_id");
                                                if (postId != null) {
                                                    Toast.makeText(mActivity,
                                                        "Posted story, id: "+postId,
                                                        Toast.LENGTH_SHORT).show();
                                                } else {
                                                    // User clicked the Cancel button
                                                    Toast.makeText(mActivity.getApplicationContext(), 
                                                        "Publish cancelled", 
                                                        Toast.LENGTH_SHORT).show();
                                                }
                                            }

                                            @Override
                                            public void onCancel() {
                                            //Display your message on dialog cancel

                                            }

                                            @Override
                                            public void onFacebookError(
                                                    FacebookError e) {
                                                Toast.makeText(mActivity.getApplicationContext(), 
                                                        e.getMessage(), 
                                                        Toast.LENGTH_SHORT).show();

                                            }

                                            @Override
                                            public void onError(
                                                    DialogError e) {
                                                Toast.makeText(mActivity.getApplicationContext(), 
                                                        e.getMessage(), 
                                                        Toast.LENGTH_SHORT).show();

                                            }
                                        });

                                    }

                                }

                        } catch (JSONException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                });
        Request.executeBatchAsync(request);


    }catch(Exception e){
        Toast.makeText(mActivity, 
                "Eexception : " + e.getLocalizedMessage(), 
                Toast.LENGTH_SHORT).show();
    }

}

});

Was it helpful?

Solution

Your application must be still in the development mode that's the reason that the post is not visible to other users since they are not developers/admins/testers of the app.

You can change the mode of your app to live in the app settings-

enter image description here

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