【问题标题】:how to save out result of curl open url https如何保存 curl 打开 url https 的结果
【发布时间】:2013-09-11 20:59:56
【问题描述】:

我尝试将 curl 结果保存到 sql 但它不起作用

 $Curl_Session = curl_init('https://graph.facebook.com/xxxxxxxxxx/feed');
 curl_setopt ($Curl_Session, CURLOPT_POST, 1);
 curl_setopt ($Curl_Session, CURLOPT_POSTFIELDS, "access_token=$ad7kfarfish&message=$message");
 curl_setopt ($Curl_Session, CURLOPT_FOLLOWLOCATION, 1);
 $a8=curl_exec ($Curl_Session);
 curl_close ($Curl_Session);

我什么都试

我试试

 $Curl_Session = curl_init('https://graph.facebook.com/xxxxxxxxxx/feed');
 curl_setopt ($Curl_Session, CURLOPT_POST, 1);
   $a8=curl_setopt ($Curl_Session, CURLOPT_POSTFIELDS, "access_token=$ad7kfarfish&message=$message");
 curl_setopt ($Curl_Session, CURLOPT_FOLLOWLOCATION, 1);
curl_exec ($Curl_Session);
curl_close ($Curl_Session);

【问题讨论】:

  • 如果要保存到数据库,请务必转义要保存的数据

标签: php curl https


【解决方案1】:

您需要告诉 cURL 返回传输:curl_setopt($Curl_Session,CURLOPT_RETURNTRANSFER,1);

然后保存响应: $response = curl_exec($Curl_Session);

【讨论】:

    【解决方案2】:

    如果您希望将响应放入变量中,您需要这样做:

    curl_setopt($Curl_Session, CURLOPT_RETURNTRANSFER, 1);
    $a8 = curl_exec($Curl_Session);
    

    如果没有这个选项,响应会被传递到客户端(除非你使用CURLOPT_FILE,它将它放在一个文件中)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-24
      • 2022-10-14
      • 1970-01-01
      相关资源
      最近更新 更多