WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm querying the twitter api when I use non secure connection http:// it works fine no wp_error (but twitter exceed limit error) but when I use https:// it works in my browser I can see the json and the xml formats, but there's an error with wp_remote_get, I tried using a second argument array('sslverify' => false) and it doesn't work either ?

so am I doing something wrong or wp_remote_get doesn't work with https ?

here's the code:

$response = wp_remote_get('https://twitter.com/statuses/user_timeline/$username.json');
if ( is_wp_error($response) ) {
echo 'wp error';

when I use http like this url


it works without the error.

I tried wp_remote_get on other apis too but always when using https it doesn't work.

thanks in advance.


I'm getting this from var_dump($response):

wp errorobject(WP_Error)#359 (2) { ["errors"]=> array(1) { ["http_request_failed"]=> array(1) { [0]=> string(146) "SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed" } } ["error_data"]=> array(0) { } }

and after using array('sslverify' => false) I'm getting from var_dump($response)

wp errorobject(WP_Error)#359 (2) { ["errors"]=> array(1) { ["http_request_failed"]=> array(1) { [0]=> string(23) "Empty reply from server" } } ["error_data"]=> array(0) { } } 
share|improve this question
Can you provide a sample URL you are using for the Twitter API without personal data, plus the exact code you are attempting the wp_remote_get with? – miahelf Apr 17 '12 at 8:02
Also, it might be helpful to know what exactly the error is, so rather than echo out a string, use print_r() or var_dump() to dump $response onto the screen. – shabushabu Apr 17 '12 at 9:37
up vote 2 down vote accepted

Ok, just noticed that you're wrapping the URL in single quotes, so the $username variable won't get interpreted. Try this instead:

wp_remote_get('https://twitter.com/statuses/user_timeline/'. $username .'.json');

Or use double quotes instead of single.

share|improve this answer
thank you very much :) I've seen something like {$username} inside urls what's the difference ? – Pierre Apr 17 '12 at 10:32
You'll still have to use double quotes when wrapping a variable in curly braces. In WP, you'll see that a lot in database calls, like this {$wpdb->prefix}some_table_name. In that case it's being used to declare the end of the variable name. Here's the link to the relevant PHP manual page: php.net/manual/en/… – shabushabu Apr 17 '12 at 10:39

Your Answer


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.