Help with CURL in PHP
I'm trying to code this in PHP:
curl -F 'access_token=123' \
-F 'message=Hello, Arjun. I like this new API.' \
https://gra开发者_如何学编程ph.facebook.com/arjun/feed
But I have no idea how to do it...
Any ideas?
Thanks
TheBounder.
You can't execute curl like this, you must first install a PHP extension (cUrl) (look here for documentation).
Then you can do things like this:
$url="https://graph.facebook.com/arjun/feed";
$ch = curl_init();
$vars = "message=YourMessage";
if($ch === FALSE){
echo "Errore init curl";
}else{
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
$returned = curl_exec($ch);
$returned = html_entity_decode($returned);
curl_close ($ch);
I just copied some code that i used some time ago, take it as a starting point.
精彩评论