I have a working facebook sharecounter. But I am having difficulty getting it to work the same way for pinterest.
Here is my function:
//sharecount fo pinterest
function get_pins() {
$pin_results = file_get_contents('http://api.pinterest.com/v1/urls/count.json?callback=receiveCount&url='. get_permalink());
$pin_array = json_decode($pin_results, true);
$pin_count = $pin_array['count'];
return ($pin_count ) ? $pin_count : "0";
}
Here is the code on wordpress theme file for the share button:
<span class="social_count"><?php echo get_pins(); ?></span>
Always returning 0.
if I test out the api with url in browser this is the json return:
receiveCount({"url":"http://example.com/2015/05/get-moving-for-mindstrong-lets-stop-the-stigma/","count":1})
here are the results of echoing $pin_results:
receiveCount({"url":"http://example.com/2015/05/get-moving-for-mindstrong-lets-stop-the-stigma/","count":2})