facebook actionscript graph api - 使用 request_ids 检索用户
如果我使用 Facebook.ui() 允许用户选择一群朋友,我如何使用返回的 request_ids 数组来访问朋友/提要?
我尝试过以下操作:
Facebook.ui("apprequests", { message:"select some friends" }, handleAppRequest, "iframe");
允许选择朋友来讲述该应用程序。然后我执行以下操作:
private function handleAppRequest(result:Object):void
{
Debug.logObject(result, this, "handleAppRequest");
for (var i:int = 0; i < result.request_ids.length; i++)
{
var requestID:String = result.request_ids[i];
Facebook.api("/" + requestID, handleRequestFriends);
}
}
选择结果对象中返回的朋友(我认为这可能是我出错的地方),然后返回失败:
private function handleRequestFriends(success:Object, fail:Object):void
{
if (success) trace("success");
else trace(fail);
}
提前感谢 ob
编辑:(新用户无法回答自己的问题)
嘿,Michiel
啊,我明白了,
应该是以下内容:
Facebook.ui("apprequests", { message:"select some friends" }, handleAppRequest, "iframe");
private function handleAppRequest(result:Object):void
{
for (var i:int = 0; i < result.request_ids.length; i++)
{
var requestID:String = result.request_ids[i];
Facebook.api("/" + requestID, handleRequestFriends);
}
}
private function handleRequestFriends(success:Object, fail:Object):void
{
if (success)
{
var values:Object =
{
access_token:Facebook.getSession().accessToken,
name:"This is my title",
link:"http://example.com",
picture:"http://example.com/facebook/facebooktutorial/canvas/images/icon-75x75.gif",
caption:"this is a caption",
message:"This is a test message on " + new Date().toString()
};
var friendID:String = success.to.id;
Facebook.api("/" + friendID + "/feed", handleSubmitFeed, values, URLRequestMethod.POST);
}
else
{
Debug.logObject(fail, this, "handleRequestFriends");
}
}
还有一个问题 - 我可以使用 facebook 好友选择器,只返回结果,而不向他们发出 apprequest ?
谢谢 观察
If I have used Facebook.ui() to allow the user to select a bunch of their friends, how can I use the returned request_ids array to access the friends /feeds please?
I've tried the following:
Facebook.ui("apprequests", { message:"select some friends" }, handleAppRequest, "iframe");
which allows the selection of friends to tell about the app. I then do the following:
private function handleAppRequest(result:Object):void
{
Debug.logObject(result, this, "handleAppRequest");
for (var i:int = 0; i < result.request_ids.length; i++)
{
var requestID:String = result.request_ids[i];
Facebook.api("/" + requestID, handleRequestFriends);
}
}
to select the friends returned in the result object (which I think might be where I'm going wrong), and then this returns a fail:
private function handleRequestFriends(success:Object, fail:Object):void
{
if (success) trace("success");
else trace(fail);
}
Thanks in advance
ob
EDIT: (new users can't answer their own question)
Hey again Michiel
ah i got it
it should be the following:
Facebook.ui("apprequests", { message:"select some friends" }, handleAppRequest, "iframe");
private function handleAppRequest(result:Object):void
{
for (var i:int = 0; i < result.request_ids.length; i++)
{
var requestID:String = result.request_ids[i];
Facebook.api("/" + requestID, handleRequestFriends);
}
}
private function handleRequestFriends(success:Object, fail:Object):void
{
if (success)
{
var values:Object =
{
access_token:Facebook.getSession().accessToken,
name:"This is my title",
link:"http://example.com",
picture:"http://example.com/facebook/facebooktutorial/canvas/images/icon-75x75.gif",
caption:"this is a caption",
message:"This is a test message on " + new Date().toString()
};
var friendID:String = success.to.id;
Facebook.api("/" + friendID + "/feed", handleSubmitFeed, values, URLRequestMethod.POST);
}
else
{
Debug.logObject(fail, this, "handleRequestFriends");
}
}
One question tho - can i use the facebook friend selector and just return the results without the apprequest firing off to them?
thanks
ob
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我再次建议您使用参数来发送 access_token,就像您之前的问题一样:)
并且我假设您正在尝试获取用户,因为如果您想发布到他们的提要,您应该只使用
编辑:顺便说一句:您确定使用此方法获得了正确的 id 吗? (之前没有访问过朋友列表,所以我不知道)。
i would again suggest that you use the params to send your access_token, like in your previous question :)
and i assume you are trying to get the user, because if you want to post to their feed, you should just use
edit: btw: are you sure you are getting the right id's with this method? (haven't accessed friends list before, so i have no idea).