Answer the question
In order to leave comments, you need to log in
How to fix cURL error(7)?
Hi all! there is a code that interacts with the Yandex API
$method3 = 'GetWordstatReportList';
$request3 = array(
'token' => $token,
'method' => $method3,
);
$request3 = json_encode($request3);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $serv_addr); // set url to post to
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
curl_setopt($ch, CURLOPT_POST, 1); // set POST method
curl_setopt($ch, CURLOPT_HTTPHEADER, $post_headers); // set POST method
curl_setopt($ch, CURLOPT_POSTFIELDS, $request3); // add POST fields
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$response = curl_exec($ch); //получил ответ от сервера
if($errno = curl_errno($ch)) {
$error_message = curl_strerror($errno);
echo "cURL error ({$errno}):\n {$error_message}";
}
curl_close($ch);
if ($response === false) {
die("Произошел сбой. Попробуйте еще раз");
print_r($response);
echo $response;
}
$result3 = json_decode($response, true);
if (!isset($result3))
die("JSON decode error. " . $response);
if (!isset($result3['data']))
die("Element 'data' not found. " . $response);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question