I want to send a request to :
https://api.nobitex.ir/
Like this : https://api.nobitex.ir/v2/orderbook/BTCUSDT
in php or laravel.
Can someone help me ?
Advertisement
Answer
Use below funtion to call url with php curl
function call_url_service_curl($service_url) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $service_url); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_FORBID_REUSE, true); curl_setopt($curl, CURLOPT_USERAGENT, 'api'); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0); curl_setopt($curl, CURLOPT_TIMEOUT, 10); curl_setopt($curl, CURLOPT_FRESH_CONNECT, true); curl_setopt($curl, CURLOPT_DNS_CACHE_TIMEOUT, 0); curl_setopt($curl, CURLOPT_ENCODING , "gzip"); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE); // http to https or www to non www url available curl_setopt($curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); $result = curl_exec($curl); curl_close($curl); return $result; }
and usage is
$result = call_url_service_curl('https://api.nobitex.ir/v2/orderbook/BTCUSDT'); echo '<pre>'; print_r($result); die();