facebook actionscript graph api - 使用 request_ids 检索用户

发布于 2024-11-01 04:14:32 字数 2041 浏览 0 评论 0原文

如果我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

默嘫て 2024-11-08 04:14:32

我再次建议您使用参数来发送 access_token,就像您之前的问题一样:)

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"); 
    }
}

并且我假设您正在尝试获取用户,因为如果您想发布到他们的提要,您应该只使用

var _params:Object = new Object();
_params.access_token = Facebook.getSession().accessToken;
_params.message = _message;
Facebook.api("/" + requestID + "/feed", handleRequestFriends, _params, "POST"); 

编辑:顺便说一句:您确定使用此方法获得了正确的 id 吗? (之前没有访问过朋友列表,所以我不知道)。

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文