What is the reason for the curl error in php? what is the reason for Warning: curl_setopt (), seeking advice?

An error occurred during

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?

May.28,2021

make good use of Baidu

There are two

solutions, one is to rewrite follow, and the other is to turn off follow,. There are

here.

http://www.php.net/manual/en/.


the option to enable CURLOPT_FOLLOWLOCATION requires setting the open_basedir option in PHP.ini, mainly because of security issues.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b33ca7-2bece.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b33ca7-2bece.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?