curl:
Warning: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set in H:\htdocs\minapp\token.php on line 31
Code:
<?php
ini_set("display_errors", true);
error_reporting(E_ALL);
$param = [
"client_id" => "xxxxxxba31",
"client_secret" => "xxxxx02bcda1c6a9e",
];
// code
$code_url = "https://xxx.a.com/";
$code_data = postData ($code_url, json_encode ($param));
$code_data = json_decode ($code_data, true);// code Access Token
// echo $code_data;
$param["code"] = $code_data["code"];
$param["grant_type"] = "authorization_code";
$access_token_url = "https://xxx.a.com/api/";
$access_token = postData ($access_token_url, $param, "multipart/form-data"); // Access Token
print_r ($access_token);
//
function postData($url, $param, $content_type = "application/json")
{
$ch = curl_init ();
curl_setopt ($ch, CURLOPT_TIMEOUT, 30);
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $param);
31 curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); //
curl_setopt ($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt ($ch, CURLOPT_COOKIEFILE, "");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_COOKIESESSION, true);
curl_setopt ($ch, CURLINFO_CONTENT_TYPE, $content_type); // Content-Type application/json
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, true);
$response = curl_exec ($ch);
curl_close ($ch);
return $response;
}
what is the reason for asking? Do you need to set it in php.ini?