-1

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 ?

  • Does this answer your question? [PHP, cURL, and HTTP POST example?](https://stackoverflow.com/questions/2138527/php-curl-and-http-post-example) – user3783243 Jun 01 '22 at 13:38

2 Answers2

0

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();
Berk Kanburlar
  • 260
  • 2
  • 11
-4

Use this website it converts your curl request to any langauge

Dean Van Greunen
  • 5,060
  • 2
  • 14
  • 28