喜欢在Facebook图表api的帖子 [英] Like posts over Facebook graph api
问题描述
HI!我有一点问题的Facebook PHP SDK ..我想要一个帖子,或其他东西通过Facebook PHP SDK ..我正在做这个代码,我认为这应该是正确的,但显然它不工作。给定的错误代码是,PHP SDK不知道这种POST请求(生成的链接肯定是正确的)。我在Facebook开发人员页面上看到的是大致相同的。有一个Curl命令的例子,我的PHP SDK正在通过Curl(可推荐地)执行这个请求。
HI! I have little problem with facebook PHP SDK..I want to like a post, or something else via facebook PHP SDK..I am doing this code, I think it should be right, but apparently it's not working..The given error code is, the PHP SDK dont know this kind of POST request(the generated link is definitely alright). What I have seen on Facebook Developers page is about the same..There is an example of Curl command, and I the PHP SDK is doing this requests over Curl (propably).
$ this-> getFacebook() - > api(/+ $ id +/ likes,'post');
在我的代码中,它不工作(Facebook API异常不支持的发布请求)。
$this->getFacebook()->api("/"+$id+"/likes", 'post');
This is what I am using in my code and it's not working(Facebook API Exception unsupported post request).
也许,我的代码中有不好的语法,但是,例如,当我想发布一个状态到我的个人资料,它的工作。另一个原因困惑我,是当我试图通过图形API获取这些数据(在文档页面上写,我应该使用地址,如 graph.facebook .com / POST_ID / likes
)...
Maybe, I have bad syntax in my code, but, for example, when I want to post a status to my Profile, it's working..Another cause which confused me, was when I tried to fetch these data over Graph api(on the documentation page is written, I should use address like graph.facebook.com/POST_ID/likes
)...
您可以通过发帖到 https://graph.facebook.com/POST_ID/comments
和 https://graph.facebook.com/ POST_ID /喜欢
,分别:
curl -F'access_token = ... '\
< =这是来自facebook文档
https:// graph.facebook.com/313449204401/likes
curl -F 'access_token=...' \
https://graph.facebook.com/313449204401/likes
<=this is from facebook documentation
所有这些请求或命令(喜欢,评论我还没有尝试过)把我放回一个JSON数组,它包含已经存在的所有喜欢的内容,但是我的喜欢是无处的。
And all these requests or commands(liking ones, comments have I not yet tried) are putting me back a JSON array which contents any already existing likes, but my like is nowhere.
有谁知道该怎么办?像PHP的一个帖子。有其他的SKD像FQL,但我没有任何知识,所以我喜欢使用标准的PHP SDK(但如果有一些可能性如何调用例如FQL从PHP SDK ,这里我是:))
Does anyone know what to do?How to like a post from PHP..There are other SKDs like FQL, but I haven't any knowlegde with it, so I like rather to use the standard PHP SDK(but if is there some possibility how to call for example FQL from PHP SDK, here I am:))
请帮助..
推荐答案
好的,经过几次测试,在发送参数时不要使用加号 +
,因为ID将作为参数发送到没有
方法,所以使用: /
和 /喜欢
的api
Okay, after a couple of tests don't use the plus sign +
when sending the parameter as the ID alone will be send as argument to the api
method without /
and /likes
so use:
$this->getFacebook()->api("/".$id."/likes", 'post');
甚至更好:
$this->getFacebook()->api("/$id/likes", 'post');
还要确保你有 publish_stream
扩展许可,请参阅此文档。
Also make sure that you have the publish_stream
extended permission, refer to this document.
这篇关于喜欢在Facebook图表api的帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!