• Resolved Jayaram Maharjan

    (@shovan_jaya)


    Hi everyone,

    Have any one noticed that after the wordpress update to version 4.6 the wordpress function wp_remote_get() is not working? But before wordpress update it was working correctly.

    I’m getting error like this

    WP_Error Object (
    [errors] => Array (
    [http_request_failed] => Array ( [0] => cURL error 3: malformed ) ) [error_data] => Array ( )
    )

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Dion Hulse

    (@dd32)

    Meta Developer

    @shovan_jaya can you post some details about how you’re using wp_remote_get()?

    The underlying library was switched to using the Requests library in WordPress 4.6.

    The specific error you’re getting indicates that an invalid URL format was passed to cURL, that could be from your input or a redirect that’s happening on the URL.

    Are you able to share the URLs you’re trying to access publicly? (If not, you could email them to me privately at dion (at) wordpress (dot) org to take a look)

    Thread Starter Jayaram Maharjan

    (@shovan_jaya)

    Hello @dion Hulse,

    Thank you for your response ??

    I figure out the issue. There was a double ‘//’ in the url (https://graph.facebook.com//oauth/access_token?client_id=%s&client_secret=%s&grant_type=client_credentials) due to which the issue was appearing. After I removed the ‘//’ from the url with single ‘/’ the issue got resolved.

    function get_fb_access_token(){
        $apsc_settings = $this->apsc_settings;
        $api_url = 'https://graph.facebook.com/';
            $url = sprintf(
                '%s/oauth/access_token?client_id=%s&client_secret=%s&grant_type=client_credentials',
                $api_url,
                $apsc_settings['social_profile']['facebook']['app_id'] ,
                $apsc_settings['social_profile']['facebook']['app_secret']
            );
            $access_token = wp_remote_get( $url, array( 'timeout' => 60 ) );
    
            if ( is_wp_error( $access_token ) || ( isset( $access_token['response']['code'] ) && 200 != $access_token['response']['code'] ) ) {
                return '';
            } else {
                return sanitize_text_field( $access_token['body'] );
            }
        }
    Moderator Dion Hulse

    (@dd32)

    Meta Developer

    Thanks for reporting back! I’ll take a look into this and see if there’s a bug we need to report upstream.

    (Edit: See https://github.com/rmccue/Requests/issues/231 upstream)

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘wp_remote_get is not working after wordpress update to 4.6’ is closed to new replies.