Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
139 views
in Technique[技术] by (71.8m points)

android - Facebook me/feed can only post on developers account only

I am encountering a strange situation here.While posting to facebook I want my app to bypass the dialog the asks to write something and show my own customize dialog.For that reason I have to use "me/feed".The app works fine when I post something in the developers account.But when I try to post in some other account it sometime returns nothing or sometime returns:

08-21 12:26:29.332: D/Facebook-Util(6796): POST URL: https://graph.facebook.com/me/feed
08-21 12:26:29.722: D/Tests(6796): got response: {"error":{"message":"(#200) The user hasn't authorized the application to perform this action","type":"OAuthException","code":200}}

I am really confused about what mistake I am doing here.Why the message is not posting other than the developers account..?

This is my relevant code:

if (facebook.isSessionValid()) {
                            facebook.authorize(BoonDriveActivity.this,
                                    new String[] { "publish_stream","publish_actions","manage_pages","status_update"},//This are the permissions
                                    new DialogListener() {

                                        @Override
                                        public void onCancel() {
                                            // Function to handle cancel event
                                        }

                                        @Override
                                        public void onComplete(Bundle values) {
                                            // Function to handle complete event
                                            // Edit Preferences and update facebook acess_token
                                            final SharedPreferences.Editor editor = mPrefs.edit();
                                            editor.putString("access_token",
                                                    facebook.getAccessToken());
                                            editor.putLong("access_expires",
                                                    facebook.getAccessExpires());
                                            editor.commit();
                                            LayoutInflater inflater=BoonDriveActivity.this.getLayoutInflater();
                                            View layout=inflater.inflate(R.layout.createsharedialoglinkedin,null);
                                            final AlertDialog d1 = new AlertDialog.Builder(BoonDriveActivity.this)
                                            // Your other options here ...
                                            .setView(layout)
                                            .create();//My custom dialog
                                            d1.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
                                            d1.show();
                                            lntxtfilename=(TextView)layout.findViewById(R.id.txtfilename);
                                            lnetmessage=(EditText)layout.findViewById(R.id.et_message);
                                            ln_btn_share=(Button)layout.findViewById(R.id.btn_share);
                                            ln_btn_showlink=(Button)layout.findViewById(R.id.btn_showlink);
                                            lnshowlink=(EditText)layout.findViewById(R.id.et_showlink);
                                            ln_btn_share.setText("SHARE ON FACEBOOK");
                                            ln_btn_showlink.setOnClickListener(new View.OnClickListener() {

                                                @Override
                                                public void onClick(View v) {
                                                    // TODO Auto-generated method stub
                                                    ln_btn_showlink.setVisibility(View.GONE);
                                                    lnshowlink.setVisibility(View.VISIBLE);
                                                    lnshowlink.setText(finallink);
                                                }
                                            });
                                            lntxtfilename.setText("Share"+" "+filename+" "+"with:");

                                            ln_btn_share.setOnClickListener(new View.OnClickListener() {

                                                @Override
                                                public void onClick(View v) {
                                                    // TODO Auto-generated method stub
                                                    //String s = ((GlobalFilename)BoonDriveActivity.this.getApplication()).getGlobalState();
                                                    if(lnetmessage.length()==0)
                                                    {
                                                        Toast.makeText(BoonDriveActivity.this,"Please enter message",Toast.LENGTH_LONG).show();
                                                    }
                                                    else{
                                                    String share1 = lnetmessage.getText().toString();
                                                    //String finalmsg=share1+"
"+s;
                                                    System.out.println("This is the final msg linkedin--->"+ finallink);
                                                    //lnetmessage.setText(finalmsg);
                                                    //postToWall();
                                                    postToWall(share1,finallink);
                                                     d1.dismiss();
                                                    }
                                                }
                                            });



                                        }

                                        @Override
                                        public void onError(DialogError error) {
                                            // Function to handle error

                                        }

                                        @Override
                                        public void onFacebookError(FacebookError fberror) {
                                            // Function to handle Facebook errors

                                        }

                                    });
                        }



                    } 

I searched a lot about this,but couldn't find a solution.Please help.

I am using the following method to post to wall:

@SuppressWarnings("deprecation")
    public void postToWall(String message,String link){

        Bundle parameters = new Bundle();

                parameters.putString("message", message+link);
               // parameters.putString("link",link);
               /* parameters.putString("description", "topic share");
                parameters.putString("picture", link);*/
                try {
                     String response = facebook.request("me");
                    facebook.request("me");
             response = facebook.request("me/feed", parameters, "POST");
            Log.d("Tests", "got response: " + response);
            if (response == null || response.equals("") ||
                    response.equals("false")) {
                showToast("Blank response.");
            }
            else {
                showToast("Message posted to your facebook wall!");
            }

        } catch (Exception e) {
            showToast("Failed to post to wall!");
            e.printStackTrace();

        }
    }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If your app hasn't been reviewed yet, no other users than the admins and developers of this app are able to give to appropriate permissions.

This is described in the docs:

Quote:

If you're the developer of an app and are the only person using it, then your app doesn't need to go through review. Since you're the developer, all app capabilities should be available. You will still need to take your app out of developer mode, but you should be able to do that without going through review.

And, BTW, there is no status_update permission...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...