在Facebook Graph API上使用POST请求 [英] using POST request on Facebook Graph API

查看:173
本文介绍了在Facebook Graph API上使用POST请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想访问图形API以获取网站不同页面的份额数.我可以使用GET方法来执行此操作,但我想使用POST,以便可以在单个请求中发送更多url.我目前对GET的实现是

解决方案

此文档记录不充分(我是说我在寻找信息时找不到信息!),但是有一种方法可以将所有参数传递给通过POST方法的Graph API: 在您的示例中,您应该发布到 http://graph.facebook.com/ 具有以下数据: ids = http://umairj.com/,http://umairj.com/146/how-to-clear-facebook-shares-cache/& method = GET

我不确定POST DATA的编码..在我们的情况下,我们只是使用ids = .....,.....,.....以及数字FB用户ID和我们不需要进行任何编码,但是您可能需要一些url-encoding

请不要忘记& method = GET,否则它将无法正常工作!当我们通过GET传递太多ID时,它帮助我打破了导致Internet Explorer出现错误的URL长度限制(我认为RFC说1024个字符,所有浏览器都支持更多,IE仅〜4096)

如果您希望访问非公开信息,则可以使用 https://graph.facebook.com/使用相同的技巧,前提是您在查询中添加了& session_token = * ****

I want to access graph API to get the number of shares for different pages of my website. I can use the GET method to do so but I want to use POST so that I can send more url in a single request. The current implementation I have for GET is

http://graph.facebook.com/?ids=http://umairj.com/,http://umairj.com/146/how-to-clear-facebook-shares-cache/

Can anyone please help ?

解决方案

This is badly documented (I mean I didn't find the information when I looked for it!), but there is way to pass all the parameters to the Graph API through POST method: in your example, you should POST to http://graph.facebook.com/ with the following DATA: ids=http://umairj.com/,http://umairj.com/146/how-to-clear-facebook-shares-cache/&method=GET

I'm not sure about the encoding of the POST DATA..in our case, we were just using ids=.....,.....,..... with numeric FB user ids and we didn't need to do any encoding, but you might need some url-encoding

Don't forget the &method=GET or it won't work ! It helped me break the url length limit that was causing bugs on Internet Explorer (I think RFC says 1024 characters, all browsers support much more, IE only ~4096 ) when we were passing too many ids through GET

if you wish to access non-public information, the same trick works with https://graph.facebook.com/ , provided you add &session_token=***** to your query

这篇关于在Facebook Graph API上使用POST请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆