开发者

Help with CURL in PHP

开发者 https://www.devze.com 2023-03-14 07:56 出处:网络
I\'m trying to code this in PHP: curl -F \'access_token=123\' \\ -F \'message=Hello, Arjun. I like this new API.\' \\

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消