Pinterest Followers display

2019-04-02 07:22发布

How would I go about showing my Pinterest followers in Wordpress? I tried this but it only displays the button letting users to follow my account, nothing about my followers.

Presumably, I can do this using the Pinterest API, but I'm unsure where to start.

Any help would be appreciated.

3条回答
\"骚年 ilove
2楼-- · 2019-04-02 07:42

Yes, you can use the Pinterest API. Install curl and use that in a PHP script. Example:

$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, 'http://pinterestapi.co.uk/"""yourname"""/likes');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 0);
$json = curl_exec($ch);
curl_close($ch);

It's supposed to return something like this note that """yourname""" is your Pinterest account name:

{
"body": [
{
"href": "http://pinterest.com/pin/150026231307331200/",
"src": "http://media-cache-ec3.pinterest.com/upload/228979962274567868_qVshovBS_b.jpg",
"desc": "#london",
"user": "Louise Earl",
"via": "Kris Mitchell",
"board": "Ideal"
},
{
"href": "http://pinterest.com/pin/287104544965407998/",
"src": "http://media-cache-ec8.pinterest.com/upload/287104544965407998_z3kbynbX_b.jpg",
"desc": "hipsters vs old people",
"user": "Lucy Foulkes",
"via": false,
"board": "cool"
}
],
"meta": {
"count": 2
}
}

Since this returns a json string you´ll need to decode it.

$count = json_decode($json, true);
$count = $count['meta']['count'];

I don't know if curl is available when hosting your site on Wordpress but might be worth a try. In your case the "count" in that string is probably what you want.

查看更多
看我几分像从前
3楼-- · 2019-04-02 07:51

I managed to do it with this plugin http://wordpress.org/plugins/pinterest-badge/

I added it as a widget. I made the number of pins = 0 and no title.

See screenshot below:

enter image description here

You can edit the styles to your liking as well as change the "Followed by..." text in the plugin files!

查看更多
\"骚年 ilove
4楼-- · 2019-04-02 08:00

Maybe it will be helpful for someone. To get the number of account followers:

<?php
$metas = get_meta_tags('http://pinterest.com/pinterest/');
print_r($metas['pinterestapp:followers']);
查看更多
登录 后发表回答