wp_remote_get doesn’t work with secure connections https?

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 ?

Read More

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

wp_remote_get('http://api.twitter.com/1/statuses/user_timeline.json?screen_name=$username');

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.

EDIT:

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) { } } 

Related posts

Leave a Reply

1 comment

  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.