Facebook API / Android : Wall Post publish with image attachment not working

后端 未结 2 747
误落风尘
误落风尘 2021-01-24 13:30

I have the following code.

It works and posts the message-part but the attachment part does\'nt work. I suspect it has to do with passing a JSON as a string.

Fac

2条回答
  •  猫巷女王i
    2021-01-24 14:09

    You can't send json encoded data to facebook, doesn't work that way. Each parameter should be on it's on in the POST body.

    In addition, the "attachment" way is an old one and not used anymore. It should look something like:

    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");
    

    An official reference for uploading images using urls can be found here: Uploading Photos to the Graph API via a URL. The parameters for posting to a feed can be found in the User object doc.

提交回复
热议问题