If I have used Faceboo开发者_如何学Pythonk.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
i would again suggest that you use the params to send your access_token, like in your previous question :)
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];
var _params:Object = new Object();
_params.access_token = Facebook.getSession().accessToken;
Facebook.api("/" + requestID, handleRequestFriends, _params, "GET");
}
}
and i assume you are trying to get the user, because if you want to post to their feed, you should just use
var _params:Object = new Object();
_params.access_token = Facebook.getSession().accessToken;
_params.message = _message;
Facebook.api("/" + requestID + "/feed", handleRequestFriends, _params, "POST");
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).
精彩评论