2013-03-08 90 views
-1

通过PHP教我自己的Facebook饲料发布,我想弄清楚如何通过PHP curl命令执行这个curl HTTP POST,有什么建议吗?Facebook POST PHP HTTP curl

curl -X POST \ 
    -F 'message=Post%20with%20app%20access%20token' \ 
    -F 'access_token=YOUR_APP_ACCESS_TOKEN' \ 
    https://graph.facebook.com/4804827/feed 

发现它的here

+0

或者这仍然是一个有效的文章? http://stackoverflow.com/questions/5814158/post-to-a-facebook-users-wall-with-curl-php – VikingGoat 2013-03-08 19:02:55

+0

http://www.php.net/manual/en/curl.examples-basic。 php – Tchoupi 2013-03-08 19:02:55

+0

您发现了一篇很好的“文章”,那么为什么在尝试之前询问它是否仍然有效? – 2013-03-08 19:07:58

回答

1

这是如何做到这一点:

$ch = curl_init(); 

curl_setopt($ch, CURLOPT_URL, "https://graph.facebook.com/4804827/feed"); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_HEADER, false); 
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
    'message' => 'Post with app access token', 
    'access_token' => 'YOUR_APP_ACCESS_TOKEN' 
)); 

echo curl_exec($ch); 
curl_close($ch); 

我建议在看文档:

http://www.php.net/manual/en/function.curl-init.php

http://www.php.net/manual/en/function.curl-setopt.php

+0

出于某种原因,我没有把两个和两个文件放在一起,现在这非常有意义,谢谢。 – VikingGoat 2013-03-08 19:12:27