创建自定义的墙后对Android的Facebook的API自定义、Android、API、Facebook

2023-09-06 05:54:54 作者:▓ 这些丶都是你给我的爱 ﹨

我是新来的在Android Facebook的API,基本上,我想要做的是为我开发一个应用程序中创建自定义的墙后。 当你听一个Shazam的一首歌曲,你可以分享的结果与你的朋友喜欢。 我相信我一定要创建一个自定义的附件。这是我的code设置附件:

I'm new to Facebook API on Android, and basically, what I'm trying to do is creating custom wall post for an application I'm developing. Like when you listen a Shazam a song and you can share the result with your friends. I believe I've got to create a custom attachment. Here's my code for setting the attachment:

mPostButton.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        Bundle myParams = new Bundle();
        String attachment="{\"name\":\"Gran Turismo 5\"," +
           "\"href\":\"http://www.unknown.com/?lang=fr\"," +
           "\"caption\":\"Sony Computer Entertainment\",\"description\":" +
           "\"Une vidéo proposée par Cedemo.\",\"media\":" +
           "[{\"type\":\"image\",\"src\":" +
           "\"https://m.xsw88.com/allimgs/daicuo/20230906/1264.png.jpg\"," +
           "\"href\":\"http://www.unknown.com/?lang=fr\"}],\"properties\":" +
           "{\"Autre lien\":{\"text\":\"Cedemo\",\"href\":\"http://www.unknown.com\"}}}";
        myParams.putString("attachment", URLEncoder.encode(attachment);
        mFacebook.dialog(Option.this, "stream.publish",myParams,
                new SampleDialogListener());

然后,后来就:

public class SampleDialogListener extends BaseDialogListener {

    public void onComplete(Bundle values) {
        final String postId = values.getString("post_id");
        if (postId != null) {
            Log.d("Facebook-Example", "Dialog Success! post_id=" + postId);
            mAsyncRunner.request(postId,values, new WallPostRequestListener());
        } else {
            Log.d("Facebook-Example", "No wall post made");
        }
    }
}

我不写的附件字符串,它只是一个试验,从本次论坛做了另一个问题所采取。无论如何,当我打电话myAsync.request,我的应用程序显示错误消息,我怎么打发依恋我的对话? 希望我已经很清楚。

I didn't wrote the attachment String, It's just a test taken from another question made in this forum. Anyway, when I call myAsync.request, my app shows an error message, how am I supposed to pass the attachment to my dialog? Hope I've been clear enough.

推荐答案

您确定您需要设置自定义的参数?这听起来像你只是想直接上传Facebook的消息在墙上:您可以通过简单地交给在消息参数为一个字符串做到这一点 - 只有当您要附加的图像等,并注意需要所有的JSON在Facebook的页面,它说使用这个API调用将不会发布状态更新,其他人可以在他们的饲料看到,它只会出现在他们的自己的墙。如果你只是想发布一个链接的消息,你就应该能够使用您的mAsyncRunner(一旦你有你的有效的Facebook会话),使用这样的:

Are you sure you need to set custom parameters? It sounds like you can just want to post a Facebook message directly to the wall: you can do this by simply handing in the message parameter as a string -- you only need all that JSON if you want to attach an image etc. And note on facebook's page it says using this api call won't post a status update that others can see on their feed, it will just appear on their own wall. If you just want to post a message with a link you should just be able to use your mAsyncRunner (once you have your valid Facebook session) using this:

String message = "Post this to my wall";
Bundle parameters = new Bundle();        
parameters.putString("message", message);   
mAsyncRunner.request("me/feed", parameters, "POST", new WallPostRequestListener());

也可以帮助,如果您发布的错误/响应code你从Facebook获得。

Also may help if you posted the error/response code you're getting from Facebook.