Recently I was working on a project where I was wanted to make a request to another website to submit data from Drupal site. PHP provides very useful method for it i.e. cURL. You can use cURL in Drupal as well but Drupal provides its own way of making HTTP Request i.e. drupal_http_request($url, array $options = array()). Here's how to use drupal_http_request() to make HTTP Request:
<?php
  $data = 'name=value&name1=value1'; // Parameters to pass to URL
  $session_name = 'SESSION_NAME';
  $session_id = 'SESSION_ID';
  $options = array(
    'method' => 'POST', // HTTP Request Type
    'data' => $data, // Parameters
    'headers' => array(
      'Content-Type' => 'application/x-www-form-urlencoded',
      'Cookie' => "{$session_name}={$session_id}",
    ),
  );
  $result = drupal_http_request('http:// example.com', $options); // Make request
?>
The function drupal_http_request($url, array $options = array()) takes two arguments, first is URL to make request and second is an array of values (optional) to make request such as method type, parameters to pass to URL, headers, etc.

Reference:

Tags
Submitted by ychaugule on