gpt4 book ai didi

Android:Facebook 3.0 使用 FQL 请求响应在 friend 墙上发帖(截至 2013 年 4 月 23 日)

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:03:39 25 4
gpt4 key购买 nike

我的应用程序生成按生日排列的 friend 的自定义 ListView 。所以我使用了 SELECT name, uid, pic_square, birthday_date FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) order by birthday_date

现在,当用户点击一个 friend (从 ListView )时,它会提示用户是否要发帖到那个 friend 墙上。我知道如何用旧方法来做,但我因为 How to send a post to Facebook friend's wall android SDK 3.0 而感到困惑.

在那个问题中:

The Facebook SDK for Android provides a method to let you publish stories from your app to a user's timeline. You can also use this method to post a status update on your user's behalf. This method uses the Graph API, and is an alternative to using the Feed Dialog

http://developers.facebook.com/docs/howtos/androidsdk/3.0/publish-to-feed/

还有:

never use Graph-API for posting on friend's wall. because it is disabled after 6, Feb 2013. FB recommend u to use Feed Dialog for posting on friend's or your own wall. this is the link for how to use Feed Dialog : http://developers.facebook.com/docs/howtos/androidsdk/3.0/feed-dialog

我看过这两个链接,但都只显示了如何在您自己的墙上发帖。谁能给我一个很好的最新示例,或者至少为我指明了如何通过 Facebook Android SDK 3.x(目前版本为 3.0.2b)使用 FQL 请求响应发布到您的 friend 墙上的正确方向?

最佳答案

我找到了解决方案。您只需要添加“to”和“from”参数。下面是我的示例:

对于单个 friend 的墙贴:

    private void publishFeedDialog(String friend_uid) {
Session session = Session.getActiveSession();
if (!hasPublishPermission()) {
// We don't have the permission to post yet.
session.requestNewPublishPermissions(new Session.NewPermissionsRequest(this, WRITE_PERMISSION));
}
if (user != null && friend_uid != null && hasPublishPermission()) {

final Activity activity = this;
Bundle params = new Bundle();
//This is what you need to post to a friend's wall
params.putString("from", "" + user.getId());
params.putString("to", friend_uid);
//up to this
params.putString("name", "Facebook SDK for Android");
params.putString("caption", "Build great social apps and get more installs.");
params.putString("description", "The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps.");
params.putString("link", "https://developers.facebook.com/android");
params.putString("picture", "https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png");
WebDialog feedDialog = (new WebDialog.FeedDialogBuilder(this, Session.getActiveSession(), params))
.setOnCompleteListener(new OnCompleteListener() {

@Override
public void onComplete(Bundle values, FacebookException error) {
if (error == null) {
// When the story is posted, echo the success
// and the post Id.
final String postId = values.getString("post_id");
if (postId != null) {
Toast.makeText(activity,
"Posted story, id: "+postId,
Toast.LENGTH_SHORT).show();
} else {
// User clicked the Cancel button
Toast.makeText(activity,
"Publish cancelled",
Toast.LENGTH_SHORT).show();
}
} else if (error instanceof FacebookOperationCanceledException) {
// User clicked the "x" button
Toast.makeText(activity,
"Publish cancelled",
Toast.LENGTH_SHORT).show();
} else {
// Generic, ex: network error
Toast.makeText(activity,
"Error posting story",
Toast.LENGTH_SHORT).show();
}
}

}).build();
feedDialog.show();
}
}

对于很多 friend 的墙贴:

RequestsDialogBuilder instead of FeedDialogBuilder because the second one only allows multiple ids on the parameter "to", while the first one can receive many (not sure about the limit though, but I think is about 50)

归功于:gian1200

关于Android:Facebook 3.0 使用 FQL 请求响应在 friend 墙上发帖(截至 2013 年 4 月 23 日),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16169456/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com