Reputation: 2810
Pinterest api works fine in the browser side to show share count for a specific URL as seen here for Google.
But when I try to call it from wp_remote_get function of Wordpress, it returns null:
$url = "http://api.pinterest.com/v1/urls/count.json?url=http://www.google.com";
$response = wp_remote_retrieve_body(wp_remote_get($url,
array ('timeout' => 30, 'sslverify' => false ) ) );
var_dump($response); // null
I want to underline that, this function block works fine when I try to get share counts of Google, Facebook or Twitter.
I also tried wp_remote_post, nothing changed with the response.
Upvotes: 0
Views: 1053
Reputation: 2810
OK, I found an answer for this problem. The wp_remote_get function returns an array which has a body. But the wp_remote_retrieve_body function can't convert it into a string since it's in the form of a javascript callback (I guess).
When I get the body directly from the response of the first array and removed the callback function as told here, I got the response json.
Upvotes: 0