无法通过Android应用程序在Facebook上发布照片

时间:2014-05-23 07:15:32

标签: android facebook facebook-graph-api

#    这是我登录后的代码,它不会在Facebook上发布照片 - #

这是我给出的权限:"电子邮件"," publish_stream"," friends_about_me"," offline_access",&#34 ; friends_birthday"," user_location"," user_birthday"

    public void onClickSelectContact(View btnSelectContact) {

    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    Bitmap bitmap = screenShot(btnSelectContact);

    System.out.println("man man "+bitmap.getHeight());
    bitmap.compress(CompressFormat.JPEG, 0, bos);

   image_array = bos.toByteArray(); 
   System.out.println("man man "+image_array);
    System.out.println("byte array:"+image_array.length);

    facebook.authorize(ac, permissions, new DialogListener() {

        public void onFacebookError(FacebookError e) {
            // TODO Auto-generated method stub

        }

        public void onError(DialogError e) {
            // TODO Auto-generated method stub

        }

        public void onComplete(Bundle values) {
            // TODO Auto-generated method stub

            Bundle params = new Bundle();
            //params.putString("method", "photos.upload");
            params.putByteArray("picture", image_array);
            params.putString("message", "this myth man");


            try {
            facebook.request(("me") + "/photos", params, "POST");

            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (MalformedURLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

}   public void onCancel() {
            }});}
登录后

显示: when i click ok it just disapear

1 个答案:

答案 0 :(得分:0)

在添加此权限 publish_actions 后尝试。 检查请求后你得到的json。在该检查中,哪个权限被拒绝。

{
 "data": [
{
  "permission": "public_profile",
  "status": "granted"
  },
  {
  "permission": "publish_actions",
  "status": "granted"
  },
  {
  "permission": "user_friends",
  "status": "declined"
  }
]
}

我猜问题是你被拒绝了一些被要求的权限。这可能是原因。 希望这有帮助。