Facebook 不会在使用 Android 的个人资料页面上显示上传的图片

发布于 2024-11-27 20:08:49 字数 1199 浏览 0 评论 0原文

我正在尝试从 Facebook 上的某个 URL 上传图片,但它没有在我的墙上发布任何图像。而当我从我朋友的帐户中尝试相同的代码时,它工作正常并在那里上传图片。我正在使用标准 facebook sdk,此代码是其名为 simple 的示例的一部分。请帮助解决这个问题。提前致谢。

           Bundle params = new Bundle();
            params.putString("method", "photos.upload");

            URL uploadFileUrl = null;
            try {
                uploadFileUrl = new URL(
                      "http://www.facebook.com/images/devsite/iphone_connect_btn.jpg");
            } catch (MalformedURLException e) {
                e.printStackTrace();
            }
            try {
                HttpURLConnection conn= (HttpURLConnection)uploadFileUrl.openConnection();
                conn.setDoInput(true);
                conn.connect();
                int length = conn.getContentLength();

                byte[] imgData =new byte[length];
                InputStream is = conn.getInputStream();
                is.read(imgData);
                params.putByteArray("picture", imgData);

            } catch  (IOException e) {
                e.printStackTrace();
            }

            mAsyncRunner.request(null, params, "POST",
                    new SampleUploadListener(), null);
        }

I am trying to upload a picture from some URL on facebook but it is not posting any image on my wall. whereas when i tried the same code from my friend's account it works fine and upload picture over there. I am using standard facebook sdk and this code is a part of its example named as simple. Kindly help in resolving this issue. Thanks in advance.

           Bundle params = new Bundle();
            params.putString("method", "photos.upload");

            URL uploadFileUrl = null;
            try {
                uploadFileUrl = new URL(
                      "http://www.facebook.com/images/devsite/iphone_connect_btn.jpg");
            } catch (MalformedURLException e) {
                e.printStackTrace();
            }
            try {
                HttpURLConnection conn= (HttpURLConnection)uploadFileUrl.openConnection();
                conn.setDoInput(true);
                conn.connect();
                int length = conn.getContentLength();

                byte[] imgData =new byte[length];
                InputStream is = conn.getInputStream();
                is.read(imgData);
                params.putByteArray("picture", imgData);

            } catch  (IOException e) {
                e.printStackTrace();
            }

            mAsyncRunner.request(null, params, "POST",
                    new SampleUploadListener(), null);
        }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最笨的告白 2024-12-04 20:08:49

找到了解决方案...只需转到 Facebook 帐户的图片和相册的隐私设置,然后单击“批准”按钮即可允许您的相册在您的帐户上可见。

found the solution...just go to the privacy setting of the facebook account for pictures and albums and then click the approve button to allow the visibility of your album on your account.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文