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) { } } 
  • 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
    Commented Apr 17, 2012 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
    Commented Apr 17, 2012 at 9:37

1 Answer 1


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.

  • thank you very much :) I've seen something like {$username} inside urls what's the difference ?
    – Pierre
    Commented Apr 17, 2012 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
    Commented Apr 17, 2012 at 10:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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