Using PHP cURL to send http get request I am able to do the HTTP GET request using cURL in my custom function, my code below works fine for me, but is there Drupal way to do this?

function some_page_callback() {
    $url = 'https://api.example.com/data';
    $accesstoken = 'SoMedGFidHThX2NvdW50eV90bWNhOkEyakJEM2ND';
    $headr = array();
    $headr[] = 'Accept: application/json';
    $headr[] = 'Authorization: Basic '.$accesstoken;

    //cURL starts
    $crl = curl_init();
    curl_setopt($crl, CURLOPT_URL, $url);
    curl_setopt($crl, CURLOPT_HTTPHEADER,$headr);
    curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($crl, CURLOPT_HTTPGET,true);
    $reply = curl_exec($crl);

    //error handling for cURL
    if ($reply === false) {
       // throw new Exception('Curl error: ' . curl_error($crl));
       print_r('Curl error: ' . curl_error($crl));
    }
    curl_close($crl);
    //cURL ends

    //decoding the json data
    $decoded_data = json_decode($reply, true);


    // putting the data into table 
      $rows = array();

      $output = '';
      // Example of theme_table().
      $output .= '&lt;h2&gt;Example&lt;/h2&gt;';
      $headers = array(t('ID'), t('Name'));

      foreach ($decoded_data['data'] as $line) {
          $tablerow = array(
          array('data' =&gt; $line['id']),
          array('data' =&gt; $line['name']),
         );
          $rows[] = $tablerow;
      }
      $output .= theme('table', array('header' =&gt; $headers, 'rows' =&gt; $rows));

return $output;
}
I ended up needing to do something like this not too long ago in a custom module. Drupal has a function called drupal_http_request() to hit the external URL. You can execute it inside a hook function if necessary in your module.

$url = 'http://my-url.com';
      $response = drupal_http_request($url);