facebook JS SDK批量请求自定义操作

facebook JS SDK批量请求自定义操作,facebook,api,object,batch-file,facebook-opengraph,Facebook,Api,Object,Batch File,Facebook Opengraph,我编写了以下方法来检查用户是否在网页上提交了3个自定义打开图操作中的任何一个: function checkOpenGraphHistory() { var actionList = new Array($('#fb1').attr("data-action"), $('#fb2').attr("data-action"), $('#fb3').attr("data-action")); var nameList = new Array($('#fb1').attr("data-

我编写了以下方法来检查用户是否在网页上提交了3个自定义打开图操作中的任何一个:

function checkOpenGraphHistory()
{
    var actionList = new Array($('#fb1').attr("data-action"), $('#fb2').attr("data-action"), $('#fb3').attr("data-action"));
    var nameList = new Array($('#fb1').attr("data-name"), $('#fb2').attr("data-name"), $('#fb3').attr("data-name"));
    var idList = new Array('#fb1', '#fb2','#fb3');
    var i = 0;

    while(i < actionList.length)
    {
    FB.api('me/' + actionList[i] + '/?fields=id&object=' + location.href,
       function (checkResponse)
       {
           --i; //the callbacks seem to be added to a queue instead of being processed per api request. Without this line, i always = actionList.length.
           if (!checkResponse)
           {
               console.log('Check: Empty response checking: ' + checkResponse.error.message);
           }
           else if (checkResponse.error)
           {
               console.log('Check: ERROR checking: ' + checkResponse.error.message);
           }
           else if (checkResponse.data.length < 1)
           {
               console.log('Check: User has not ' + nameList[i] + ' this item before.');
           }
           else
           {
               console.log('Check: User ' + nameList[i] + 'ed item before, ID: ' + checkResponse.data[0].id + " actionList.length: " + actionList.length + "and i is: " + i);
           }
       }  );
       i++;
    }
}

但是,这将返回此特定对象/url上自定义操作的多个实例,而不仅仅是有关该特定对象上特定操作的信息。用户只能对每个对象执行一次唯一操作(一对一关系),但可以对所有三个操作执行一次,因此我只想对每个操作返回一个结果,特别是无论用户是否对指定对象执行了指定操作

me/?batch=[{"method":"GET", "relative_url":"me/myNamespace:myAction/", "object":"objectURL"}]
me/?batch=[{"method":"GET", "relative_url":"me/myNamespace:myAction/", "body":"url=objectURL"}]