How to use drupal_http_request for send data? I need some help in sending data in an array (POST) to a webservice (REST). I need some examples in how to use the function drupal_http_request().

Now, I'm using cURL with PHP but I need to replace it with drupal_http_request(). And I see that it's easier to use in Drupal.

If my first page is the login (http://[ip]/users/sign_in) and I'm using "User:Pass" to enter to main page(http://[ip]/event). Then, I select the menu for view the data that I send from my form in Drupal (http://[ip]/event/mobile/management). 

How to do this with drupal_http_request()?

UPDATE:

function send_data_form_submit($form, &amp;$form_state) {

    $name = $form_state['values']['name'];
    $email = $form_state['values']['email'];

    $attendee = array(
        'name' =&gt; urlencode($name),
        'email' =&gt; urlencode($email)
    );

    $attendee = http_build_query($attendee, '', '&amp;');

    $url_login = 'http://[ip]/eventmobile/users/sign_in';
    $url_target = 'http://[ip]/eventmobile/attendee_management/attendee';

    $use  = array(
      'email' =&gt; 'root@root.com',
      'password' =&gt; '123456'
    );
    $user = http_build_query($use, '', '&amp;');

    $headers = array('Content-Type' =&gt; 'application/x-www-form-urlencoded');

    $method = 'POST';

    $result_1 = drupal_http_request(url($url_login, array(absolute =&gt; true)), $headers, $method, $user); //I get a http_code = 200. OK
    $result_2 = drupal_http_request(url($url_target,array(absolute =&gt; true)), $headers, $method, $attendee); // I get a http_code = 500. Internal Server Error


}

UPDATE 2 (Using cURL):

$attendee = array(
        'name' =&gt; urlencode($name),
        'email' =&gt; urlencode($email)
);
$userpwd = "root@root.com:123456"
   $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $url_target);
        curl_setopt($ch, CURLOPT_HEADER, TRUE);
        curl_setopt($ch, CURLOPT_FAILONERROR, TRUE);
        curl_setopt($ch, CURLOPT_TIMEOUT, 50);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        $result = curl_exec($ch);
        $getinfo = curl_getinfo($ch, CURLINFO_HTTP_CODE); //I get http_code=200

        if(preg_match('#Location: (.*)#', $result, $r))
                $url_redirect = trim($r[1]); //The URL of LOGIN

        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
        curl_setopt($ch, CURLOPT_URL, $url_redirect);
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
        curl_setopt($ch, CURLOPT_USERPWD, $userpwd);
        curl_setopt($ch, CURLOPT_FAILONERROR, TRUE);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        $page = curl_exec($ch); // Return string: Evaluating...
        $getinfo = curl_getinfo($ch, CURLINFO_HTTP_CODE); //I get http_code=200

        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
        curl_setopt($ch, CURLOPT_POST, TRUE);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $attendee);
        curl_setopt($ch, CURLOPT_FAILONERROR, TRUE);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_TIMEOUT, 50);
        $result = curl_exec($ch); // Return string: Evaluating...
        $getinfo = curl_getinfo($ch, CURLINFO_HTTP_CODE);// I get http_code=200

    curl_close($ch);
Your $url_login looks like the default URL scheme for a Ruby on Rails website that uses the devise login system. Here is a function I've used to login to a rails/devise backed web site.

/** Authenticate via Rails/Devise site */
function devise_login($email, $pass) {
   //Build up data to send to devise
   $data = array('user' =&gt; array('email' =&gt; $email, 'password'=&gt;$pass));
   //Pull the url out of the drupal settings
   $url = variable_get('devise_authentication_url', '');
   if ($url != '') {
     $response = drupal_http_request($url, array(
       'method' =&gt; 'POST', 
       'data' =&gt; json_encode($data), 
       'max_redirects' =&gt; 0,
       'headers' =&gt; array('Content-Type' =&gt; 'application/json', 'Accept' =&gt; 'application/json'))
     );

     return = json_decode($response-&gt;data); 
   }

   return FALSE;
}