Jas*_*son 4 facebook facebook-graph-api
我想使用Graph API来获取有关URL的一些信息.
它的工作原理如下:
但是,当URL包含逗号时,事情会变得复杂.对于
我们得到
http://graph.facebook.com/?ids=http%3A%2F%2Fwww.example.com%2Fname%2Csomething
是什么给了我们:
{
"error": {
"message": "(#803) Some of the aliases you requested do not exist: something",
"type": "OAuthException",
"code": 803
}
}
Run Code Online (Sandbox Code Playgroud)
如何使用URL来避免此类错误?
只需对逗号进行双重URL编码,因此请使用%252C:
http://graph.facebook.com/?ids=http%3A%2F%2Fwww.example.com%2Fname%252Csomething
它可能看起来很奇怪,因为Graph API通过以下方式识别此URL http://www.example.com/name\u00252Csomething:但我只是通过将类似按钮指向包含逗号(未编码)的URL来对其进行测试,喜欢它 - 之后它显示了此URL的1个共享图表.