2

当我执行此代码时,我正在使用 curl 从 Punchtab 获取结果我收到 curl 异常 3 未设置 URL!任何人都可以帮助我。

$tocken2 =  "https://api.punchtab.com/v1/user?access_token=".$rest->authResponse->accessToken;

  $ch1 = curl_init();
  $ca = 'c:/path/to/ca-bundle.crt';
  curl_setopt($ch, CURLOPT_URL,$tocken2);

    curl_setopt ($ch1, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt ($ch1, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch1, CURLOPT_POST, 1);
    curl_setopt($ch1, CURLOPT_REFERER, "http://locatefirms.in");        
    curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);

    $server_output = curl_exec ($ch1);
    $errorMsg = curl_error($ch1);
    $errorNumber = curl_errno($ch1);
    echo $errorMsg;
    echo $errorNumber;
    echo $server_output;exit;
4

1 回答 1

4

您的 curl 句柄是$ch1,但您将 URL 选项设置为$ch.

$ch1 = curl_init(); // initializing $ch1 here
curl_setopt($ch, CURLOPT_URL,$tocken2); // setting option to $ch

很明显,要解决这个问题,您需要将语句更改为

curl_setopt($ch1, CURLOPT_URL,$tocken2);
于 2012-11-29T07:00:17.307 回答