Pinterest 关注者显示 [英] Pinterest Followers display
问题描述
我将如何在 Wordpress 中展示我的 Pinterest 粉丝?我试过 this 但它只显示让用户关注我的帐户的按钮,没有关于我的追随者.
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.
据推测,我可以使用 Pinterest API 做到这一点,但我不确定从哪里开始.
Presumably, I can do this using the Pinterest API, but I'm unsure where to start.
任何帮助将不胜感激.
推荐答案
是的,您可以使用 Pinterest API.安装 curl 并在 PHP 脚本中使用它.示例:
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);
它应该返回类似于此注释的内容,即""yourname""" 是您的 Pinterest 帐户名称:
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
}
}
由于这会返回一个 json 字符串,因此您需要对其进行解码.
Since this returns a json string you´ll need to decode it.
$count = json_decode($json, true);
$count = $count['meta']['count'];
我不知道在 Wordpress 上托管您的网站时 curl 是否可用,但可能值得一试.在您的情况下,该字符串中的计数"可能就是您想要的.
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.
这篇关于Pinterest 关注者显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!