Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to add a line to my functions.php that does a behind-the-scenes HTTP request submitting some user information to a mailing list URL I have. I'm trying to test the code at the moment, but nothing seems to be working.

I have tried the following:

$url = 'blabla.org/mailinglist/add?' . $user_email;
$request = new WP_Http;
$result = $request->request($url);

and

wp_remote_post($url);

Neither have worked. However, if I Just copy and paste the URL into my web browser, it works fine. Please help!

Thanks,

Tre

share|improve this question
    
What exactly are you trying to send/request? Do you need to do anything with the response? When do you want the request fired off? How do you know it's not working? –  EAMann Feb 9 '12 at 21:40
    
I just want to post information to the URL. I don't want to get the contents or anything like that. But I want it to happen behind the scenes, so the person isn't redirected or anything like that. –  tr3online Feb 10 '12 at 11:14
add comment

2 Answers

up vote 1 down vote accepted

Only use wp_remote_post() if you are actually posting something.

Try using wp_remote_get() with a full url

$url = 'http://blabla.org/mailinglist/add?' . $user_email;
$results = wp_remote_get( $url );
// var_dump( $results );
share|improve this answer
add comment

perhaps you're just missing http:// ?

i.e.

$url = 'http://blabla.org/mailinglist/add?' . $user_email;

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.