Java Facebook API/Android:Wall Post发布与图像附件不工作

Java Facebook API/Android:Wall Post发布与图像附件不工作,java,facebook,facebook-graph-api,facebook-android-sdk,Java,Facebook,Facebook Graph Api,Facebook Android Sdk,我有以下代码 它工作并发布消息部分,但附件部分不工作。 我怀疑这与将JSON作为字符串传递有关 Facebook返回“{”id:“2352264673635675”},所以这不是一个错误 Bundle params = new Bundle(); params.putString("message", message); JSONObject attachment = new JSONObject(); attachment.

我有以下代码

它工作并发布消息部分,但附件部分不工作。 我怀疑这与将JSON作为字符串传递有关

Facebook返回
“{”id:“2352264673635675”}
,所以这不是一个错误

        Bundle params = new Bundle();

        params.putString("message", message);

        JSONObject attachment = new JSONObject();

        attachment.put("href", URLEncoder.encode("http://a.espncdn.com/photo/2010/0523/pg2_a_cricket_576.jpg"));
        attachment.put("name", "Cricket Fantasy");
        attachment.put("caption", "New team");
        attachment.put("description","Description about Application");

        JSONObject media = new JSONObject();

        media.put("type", "image");
        media.put("src", URLEncoder.encode("http://a.espncdn.com/photo/2010/0523/pg2_a_cricket_576.jpg"));
        media.put("href", URLEncoder.encode("http://a.espncdn.com/photo/2010/0523/pg2_a_cricket_576.jpg"));
        attachment.put("media", media);

        params.putString("attachement", attachment.toString());

        String response = mFacebook.request("me/feed", params, "POST");

你不能将json编码的数据发送到facebook,这样不行。 每个参数都应该启用,并且在帖子正文中启用

此外,“依恋”是一种古老的方式,不再使用。 它应该看起来像:

Bundle params = new Bundle();

params.putString("message", message);
params.put("name", "Cricket Fantasy");
params.put("caption", "New team");
params.put("description","Description about Application");
params.put("url", URLEncoder.encode("http://a.espncdn.com/photo/2010/0523/pg2_a_cricket_576.jpg"));

String response = mFacebook.request("me/feed", params, "POST");
使用URL上载图像的官方参考可在此处找到:。 过帐到提要的参数可以在文档中找到

Bundle params = new Bundle();
                   // params.putString("multipart/form-data", imgurl);
                    params.putByteArray("multipart/form-data",byteArray);

                    params.putString("caption", txtcaption.getText().toString());
                    /* make the API call */
                    new GraphRequest(
                            AccessToken.getCurrentAccessToken(),
                            "/me/photos",
                            params,
                            HttpMethod.POST,
                            new GraphRequest.Callback() {
                                public void onCompleted(GraphResponse response) {
                                    /* handle the result */
                                    Log.e("responseImagedata---", response.toString());

                                }
                            }
                    ).executeAsync();