You are here

4 March 2015

Sending data using POST to external url should be done by using drupal_http_request.

Source code viewer
  1. $url = 'http://browse-tutorials.com/json';
  2. $post_request = drupal_http_request($url, array(
  3. 'method' => 'POST',
  4. 'headers' => array('Content-Type' => 'application/x-www-form-urlencoded'),
  5. 'name' => 'POST data',
  6. 'description' => ' To external url in Drupal 7.',
  7. )),
  8. ));
  9.  
  10. // Decode json data if requested data is json.
  11. $result = drupal_json_decode($post_request->data));
Programming Language: PHP