Leave a Reply

1 comment

  1. I see that the question is 2 years old, but I worked hard two days to find solution of the very same problem and here is my code (for me works 100%).

    $json_string = wp_remote_request('https://clients6.google.com/rpc',
    array(
        'method'    => 'POST',
        'body'      => '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"'.rawurldecode(get_permalink()).'","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]',
        'headers' => array('Content-Type' => 'application/json')
    ));
    
    $json = json_decode($json_string['body'], true);
    
    
    
    if(isset($json[0]['result']['metadata']['globalCounts']['count'])){
       echo intval($json[0]['result']['metadata']['globalCounts']['count']);
    }else{
       echo'0';
    }
    

    The big difference from the code above is that I send request in JSON format, not as an array.