[support] Using drupal_http_request()
Saint-Genest Gwenael
gwenael.saint-genest at makina-corpus.com
Wed Nov 21 11:25:21 UTC 2007
Steve Edwards wrote:
> I've jumped in to finish up a site that someone else started (yee ha!), and I need to do two things with the user registration data:
>
> 1) Add some custom fields to the user registration form (i.e. address/city/state/zip, job title, occupation, company, etc.)
> 2) Use the data to add the user to an embedded mail list manager program (Oempro by Octeth).
>
> Oempro can generate a script that adds the data to their database, and I can post to that script. I modified the user
> registration form and added fields using hook_form_alter(), and that works fine. The next step is to use hook_user() when $op ==
> 'insert' to post the user data to the Oempro script using drupal_http_request(). This brings up two issues:
>
> 1) How can I access the user data in hook_user()? Is it part of $user at that point, or would it be in $edit? Or another place?
> 2) How do I use drupal_http_request()? Unfortunately I'm not very familiar with HTTP headers or with this function, so I'm not
> sure what to do. For instance, do I put the form data (assuming I can get to it in hook_user()) to the $data parameter in array
> form? And what do I put in the $header variable for a request like this?
>
> Thanks.
>
> Steve
Hi !
1) Yes, you can use $user to access the user data.
When a new registration is made you have :
- a call to hook_user() with op=register , without $user data
- a call to hook_user() with op=load , without $user data
- a call to hook_user() with op=validate , without $user data
( If this steps ar ok, user will be added to drupal)
- a call to hook_user() with op=load and $user contain user data
- a call to hook_user() with op=insert and $user contain user data
- a call to hook_user() with op=load and $user contain user data
2) How can you send data to you script ? GET ? POST ?
If your script can use GET datas just add them to URL. For example :
// Create URL with site name
$url = "http://www.google.fr";
// Add some GET arguments
$url .= "/search?q=drupal&&ie=utf-8&oe=utf-8&aq=t";
// Make HTTP request
$result = drupal_http_request($url);
Gwen
More information about the support
mailing list