php - Not working after moving to production server, no error, empty response -
i attempting use php curl's functions interact api made. worked fine on development machine:
function handleerrors(int $errseverity , string $errmsg, string $errfile, int $errline) { $credentials = array( "grant_type" => "password", "username" => "user", "password" => "pass" ); $errorobj = array ( "appid" => 2, "errorsource" => $errfile . " line, " . $errline, "errormessage" => $errmsg ); $curl = curl_init(); try { curl_setopt_array($curl, array( curlopt_returntransfer => 1, curlopt_url => api_base . api_auth_path, curlopt_post => 1, curlopt_postfields => http_build_query($credentials) )); $resp = curl_exec($curl); $token = json_decode($resp, true)["access_token"]; curl_setopt_array($curl, array( curlopt_url => api_base . api_error_path, curlopt_post => 1, curlinfo_header_out => 1, curlopt_httpheader => array("authorization: bearer $token"), curlopt_postfields => http_build_query($errorobj) )); $resp = curl_exec($curl); $info = curl_getinfo($curl); } catch (exception $ex) { } { curl_close($curl); }
i received token use authorization , error appropriately posted database.
however, when moved code on production server (which hosts api), no longer working. not getting "token" back.
curl_error returns empty string. $resp empy well. retrieving curlinfo_header_out outputs similar following:
post /dev_api/token http/1.1 host: xxx accept: */* content-length: 66 content-type: application/x-www-form-urlencoded
any advice appreciated.
edit:
i tried retrieving curlinfo_response_code , returned 301, yet curlinfo_effective_url returned appropriate url (i tried in browser).
Comments
Post a Comment