2 javascript php api wordpress pinterest
我如何在Wordpress中展示我的Pinterest粉丝?我尝试了这个,但它只显示按钮,让用户关注我的帐户,没有关于我的粉丝.
据推测,我可以使用Pinterest API来做到这一点,但我不确定从哪里开始.
任何帮助,将不胜感激.
Mik*_*ail 13
也许这对某人有帮助.获取帐户关注者的数量:
<?php
$metas = get_meta_tags('http://pinterest.com/pinterest/');
print_r($metas['pinterestapp:followers']);
Run Code Online (Sandbox Code Playgroud)
是的,您可以使用Pinterest API.安装curl并在PHP脚本中使用它.例:
$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);
Run Code Online (Sandbox Code Playgroud)
它应该返回类似于此注释的内容,""yourname"""是您的Pinterest帐户名称:
{
"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
}
}
Run Code Online (Sandbox Code Playgroud)
由于这会返回一个json字符串,您需要解码它.
$count = json_decode($json, true);
$count = $count['meta']['count'];
Run Code Online (Sandbox Code Playgroud)
我不知道在Wordpress上托管您的网站时是否可以使用curl,但可能值得一试.在您的情况下,该字符串中的"计数"可能是您想要的.