Facebook Graph Batch, only takes top-level access_token

孤人 提交于 2019-12-24 15:37:43

问题


I'm using the Facebook Graph Batch API to send one message / different messages to registered people's FB walls. I'm defining an access_token for each user, and the obliged top-level access_token (used as fallback, according to the doc). For the latter I just use an access_token from the users listed in the batch.

The thing is that the only user recieving the message, is the one who's access_token I used as the top-level/fallback access_token. The other users get the "(#210) User not visible" error message. I'm using 3 test users setup at my app-roles.

Any idea what goes wrong here?

Here's my code (python) for generating one message to all registrants:

    for soc_reg in self.registrants:
        batch_item = {
            "method" : "POST",
            "relative_url" : FACEBOOK_URL_FEED % (soc_reg['uid']),
            "body" : Helper.toURL(publishParams),
            "access_token" : soc_reg['access_token'],
        }
        batch.append(batch_item)
    params = {
        "access_token" : self.registrants[0]['access_token'], # used as fallback
        "batch" : Helper.toJSON(batch),
    }

results in following value for "params":

{"access_token": "XYZ", "batch": "[{\"body\": \"caption=&message=is+not+a+test.%0D%0AWe%27re+just+rappin%27+to+the+beat%21&place=146270405429726&link=&description=\", \"access_token\": \"XYZ\", \"method\": \"POST\", \"relative_url\": \"/100003720771245/feed\"}, {\"body\": \"caption=&message=is+not+a+test.%0D%0AWe%27re+just+rappin%27+to+the+beat%21&place=146270405429726&link=&description=\", \"access_token\": \"ZYX\", \"method\": \"POST\", \"relative_url\": \"/100003671211957/feed\"}, {\"body\": \"caption=&message=is+not+a+test.%0D%0AWe%27re+just+rappin%27+to+the+beat%21&place=146270405429726&link=&description=\", \"access_token\": \"YZX\", \"method\": \"POST\", \"relative_url\": \"/100003683601909/feed\"}]"}

So the only user recieving the message is the one defined here: "access_token" : self.registrants[0]['access_token'] When I adjust the index, I can determine the one recieving the message ;)


回答1:


OK, seems like the documentation and the API itself are not corresponding: https://developers.facebook.com/bugs/212455918831996

Documentation says: relative_url => 'alias', 'body' => '{"access_token" => "..."}'

But only this ways seems to work: 'relative_url' => 'alias?access_token=...'

FB seemed to have confirmed the bug and put it on the 'wishlist', so far the latter is the way to go, works for me at least :)



来源:https://stackoverflow.com/questions/10396911/facebook-graph-batch-only-takes-top-level-access-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!