how to use cURL in facebook graph api request

前端 未结 1 990
我寻月下人不归
我寻月下人不归 2021-01-01 02:05

I am getting the information to facebook graph api using file_get_contents()

but sometimes I am receiving an error.

I found out that cURL must be used instea

1条回答
  •  囚心锁ツ
    2021-01-01 02:22

        $graph_url= "https://graph.facebook.com/me/photos";
      $postData = "url=" . urlencode($photo_url)
      . "&message=" . urlencode('')
      . "&access_token=" .$access_token;
                    
            $ch = curl_init();
    
            curl_setopt($ch, CURLOPT_URL, $graph_url);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    
            $output = curl_exec($ch);
    
            curl_close($ch);
    

    0 讨论(0)
提交回复
热议问题