采用了Android Facebook的SDK我如何可以张贴在朋友的墙上的文字

问题描述:

我试图使用Android的Facebook SDK,使用户的朋友的墙后。我已经成功地发布到使用类似呼叫用户自己的新闻提要。由于我目前的code,后到朋友工作顺利,但该消息是空白。没有任何附着物似乎工作。它显示了作为朋友的墙面完全空白的帖子。

I am trying to use the Android Facebook sdk to make a post on the user's friend's wall. I have successfully posted to the user's own news feed using similar calls. With my current code, the post to a friend works without a hitch, except that the message is blank. None of the attachments seem to work. It shows up as a completely blank post on the friend's wall.

这是在code我使用的:

This is the code I am using:

private void publishChallengeToFriend() {
    String description = 
        "I challenge you to " + m_challenge.getTitle() + "!" + 
        " I finished this challenge with a score of " + getScore() + "."
        + " Can you beat that?";

    Bundle params = new Bundle();
    params.putString(Facebook.TOKEN, m_facebook.getAccessToken());
    params.putString("message", "");
    params.putString("name", "You have been challenged!");
    params.putString("caption", "Mobile Challenges");
    params.putString("description", description);
    try{
    m_facebook.request(getFriendId() + "/feed",params, "POST");
    }
    catch (Exception e){
        Log.d("TAG", "Facebook Error: " + e.getLocalizedMessage());
    }
}

我已经授权的用户,我知道的作品,因为我可以张贴到用户自己的饲料。我知道的GitHub的问题#166在 https://github.com/facebook / Facebook的Andr​​oid的SDK /问题/ 166 。使用putByteArray()每个附件通过调用getBytes()构造每个字符串我想传递我都试过了。这仍然显示了作为朋友的墙上空白的帖子。

I have already authorized the user, and I know that works because I can post to the user's own feed. I am aware of the github issue #166 at https://github.com/facebook/facebook-android-sdk/issues/166. I have tried using putByteArray() for each of the attachments by calling getBytes() on each string I would like to transmit. This still shows up as a blank post on the friend's wall.

我愿意用张贴在朋友的墙的任何方法,它并没有成为一个Facebook请求。我也用asyncfacebookrunner.request(),并有同样的问题。理想情况下,我想用一个对话框来证明这一点,但我不知道如何使用对话框()函数的朋友的帖子。然而,我利用它来进行状态更新顺利。

I am open to using any method of posting on the friend's wall, it doesn't have to be a facebook request. I have also used asyncfacebookrunner.request() and have had the same problem. Ideally, I would like to use a dialog to show this, but I have no idea how to use the dialog() function for friend posts. I use that for status updates without a hitch, however.

感谢您!

正在把消息作为描述,尝试将其移动到信息参数,该说明参数是一个链接,你放在说明发布,并且会在链接下。它不会显示在您的文章,因为你没有连接任何东西!你可以看到我的方法做如下:

You are putting the message as the description, try moving it to the message parameter, the "description" parameter is a description of a link that you put in the post and will appear under the link. It wont show on your post because your not linking anything! You can see my method for doing it below:

protected void postToWall(String userID){
    try {
        if (isSession()) {
            String response = mFacebook.request((userID == null) ? "me" : userID);

            Bundle params = new Bundle();
            params.putString("message", "put message here");
            params.putString("link", "http://mylink.com");    
            params.putString("caption", "{*actor*} just posted this!");
            params.putString("description", "description of my link.  Click the link to find out more.");
            params.putString("name", "Name of this link!");
            params.putString("picture", "http://mysite.com/picture.jpg");

            response = mFacebook.request(((userID == null) ? "me" : userID) + "/feed", params, "POST");       

            Log.d("Tests",response);
            if (response == null || response.equals("") || 
                    response.equals("false")) {
                Log.v("Error", "Blank response");
            }
        } else {
            // no logged in, so relogin
            Log.d(TAG, "sessionNOTValid, relogin");
            mFacebook.authorize(this, PERMS, new LoginDialogListener());
        }
    }catch(Exception e){
        e.printStackTrace();
    }
}

这是结果,所以你可以看到不同的参数显示在后:

this is the result so you can see where the different parameters appear on the post: