i developed script php use console, command php index.php
.
in script, use curl query server.
the problem script shows logs on console, , want result of echo.
do have idea hide these logs?
// token // ///////////////////////////////////////////////////////////////////////////// $url = "some/url"; $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_userpwd, "$user:$pwd"); curl_setopt($ch, curlopt_ssl_verifyhost, 0); curl_setopt($ch, curlopt_ssl_verifypeer, 0); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_verbose, 1); curl_setopt($ch, curlopt_header, 1); $data = curl_exec($ch); $location = ""; preg_match_all('/^location:(.*)$/mi', $data, $location); $location = trim($location[1][0]); $location = parse_url($location); parse_str($location['query'], $attrs); $token = $attrs['code']; if( isset($token) ) { // connexion // ///////////////////////////////////////////////////////////////////////// $url = "some/url"; $post_data = ['code' => $token, 'grant_type' => 'authorization_code']; $ch = curl_init(); curl_setopt($ch, curlopt_post, true); curl_setopt($ch, curlopt_ssl_verifyhost, 0); curl_setopt($ch, curlopt_ssl_verifypeer, 0); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_userpwd, "$client_id:$client_secret"); curl_setopt($ch, curlopt_postfields, $post_data); curl_setopt($ch, curlopt_returntransfer, 1); $data = json_decode(curl_exec($ch)); $connexion = isset($data->access_token) ? $data->access_token : $data->error_description; // login // ///////////////////////////////////////////////////////////////////////// $url = "some/url"; $ch = curl_init(); curl_setopt($ch, curlopt_ssl_verifyhost, 0); curl_setopt($ch, curlopt_ssl_verifypeer, 0); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_url, $url); $data = curl_exec($ch); $data = json_decode($data); // $login = json_encode(['public' => $data->api_keys[1]->public, 'secret' => $data->api_keys->secret]); // request // ///////////////////////////////////////////////////////////////////////// $url = $request . "?externalid=".$external_id."&externalsource=".$external_source; date_default_timezone_set("europe/paris"); $nonce = generaterandomstring(); file_put_contents('php://stderr', print_r("set random nonce " . $nonce . "\n", true)); $created = date("y-m-dth:i:sp"); $created = date("y-m-dth:i:sp"); $username = $data->api->public; $secret = $data->api->secret; $pwd_digest = base64_encode(sha1($nonce.$created.$secret)); $auth_header = "x-wsse: usernametoken username=\"$username\", passworddigest=\"$pwd_digest\", nonce=\"$nonce\", created=\"$created\""; $header = array($auth_header, 'accept: something', 'accept-language: en'); $ch = curl_init(); curl_setopt($ch, curlopt_httpheader, $header); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_ssl_verifyhost, 0); curl_setopt($ch, curlopt_ssl_verifypeer, 0); $data = curl_exec($ch); $data = json_decode($data); echo $data->nbnqpoints; } else { echo "0"; }
answer found @ address: managing curl output in php
i add line every curl instance :
curl_setopt($ch, curlopt_verbose, 0);
Comments
Post a Comment