朋友们,我在没有对话的Facebook好友墙上发布了音频链接。我可以在Facebook内播放发布的音频链接,但我无法给它的标题,名称。参考图片-我想发表喜欢

。。

以下是我的代码:
try{
String userID="1000021233268431111";
Bundle params = new Bundle();
params.putString("name", "name of link");
params.putString("title", "title of link");
params.putString("descrption", "descrption of link");
params.putString("caption", "Get utellit to send messages like this!");
params.putString("link", "http://www.looptvandfilm.com/blog/Radiohead%20-%20In%20Rainbows/01%20-%20Radiohead%20-%2015%20Step.MP3");
params.putString("type", "mp3");
params.putString("source", "http://www.looptvandfilm.com/blog/Radiohead%20-%20In%20Rainbows/01%20-%20Radiohead%20-%2015%20Step.MP3");
String response = facebook.request(((userID == null) ? "me" : userID) + "/feed", params, "POST");
Log.v("response", response);
} catch(Exception e){
}如果我尝试使用JSON数组来添加附件,在参数中没有添加任何东西,并且我得到的是空帖子,如下所示:

使用JSON数组mu代码是:
Bundle parameters = new Bundle();
JSONObject attachment = new JSONObject();
try {
JSONObject media = new JSONObject();
media.put("type", "mp3");
media.put("src", "http://www.looptvandfilm.com/blog/Radiohead%20-%20In%20Rainbows/01%20-%20Radiohead%20-%2015%20Step.MP3");
media.put("title", "Listen to your message");
media.put("artist", "By: utellit for Android");
media.put("album", "Utellit");
attachment.put("media", new JSONArray().put(media));
} catch (JSONException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
attachment.put("message", "Messages");
attachment.put("name", "Get utellit to send messages like this!");
attachment.put("href", "http://www.looptvandfilm.com/blog/Radiohead%20-%20In%20Rainbows/01%20-%20Radiohead%20-%2015%20Step.MP3");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
parameters.putString("attachment", attachment.toString());
String response =facebook.request(((userID == null) ? "me" : userID) + "/feed",parameters, "POST");
Log.v("response", response);发布于 2011-09-28 18:54:49
我终于明白了..以下是我的解决方案:
try{
String link="LINK that should goes if yoy click Get utellit to send messages like this";
String amazon_link=".mp3 link that should play inside Facebook";
Bundle parameters = new Bundle();
JSONObject attachment = new JSONObject();
try {
JSONObject media = new JSONObject();
media.put("type", "mp3");
media.put("src", amazon_link);
media.put("title", "Listen to your message");
media.put("artist", "By: utellit for Android");
media.put("album", "Utellit");
attachment.put("media", new JSONArray().put(media));
} catch (JSONException e1) {}
try {
attachment.put("message", "Messages");
attachment.put("name", "Get utellit to send messages like this!");
attachment.put("href", link);
} catch (JSONException e) {}
parameters.putString("attachment", attachment.toString());
parameters.putString("message", "Text is lame. Listen up:");
parameters.putString("target_id", "xxxx"); // target Id to post
parameters.putString("method", "stream.publish");
String response = facebook.request(parameters);
}catch(异常e){}
在facebook.request方法中,我们应该只发送参数,而post的方法应该添加到附件中
最后,我在Facebook上的帖子看起来像这样:

https://stackoverflow.com/questions/7581084
复制相似问题