【问题标题】:Pinterest Followers displayPinterest 关注者显示
【发布时间】:2013-09-11 04:11:53
【问题描述】:

如何在 Wordpress 中显示我的 Pinterest 关注者?我试过this,但它只显示让用户关注我的帐户的按钮,而不是我的关注者。

大概,我可以使用 Pinterest API 做到这一点,但我不确定从哪里开始。

任何帮助将不胜感激。

【问题讨论】:

标签: php javascript wordpress api pinterest


【解决方案1】:

也许它会对某人有所帮助。 要获取帐户关注者的数量:

<?php
$metas = get_meta_tags('http://pinterest.com/pinterest/');
print_r($metas['pinterestapp:followers']);

【讨论】:

    【解决方案2】:

    是的,您可以使用 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);
    

    它应该返回类似于“你的名字”是你的 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
    }
    }
    

    由于这会返回一个 json 字符串,因此您需要对其进行解码。

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

    我不知道在 Wordpress 上托管您的网站时是否可以使用 curl,但可能值得一试。在您的情况下,该字符串中的“计数”可能就是您想要的。

    【讨论】:

    • np 很高兴我能帮助你:D。也感谢你的赏金。
    【解决方案3】:

    我设法用这个插件http://wordpress.org/plugins/pinterest-badge/做到了

    我将它添加为小部件。我将引脚数设置为 0 并且没有标题。

    请看下面的截图:

    您可以根据自己的喜好编辑样式以及更改插件文件中的“跟随...”文本!

    【讨论】:

    • 我认为您的解决方案或多或少对我有用。但我计划在完成主题和内容后将我的网站托管在wordpress.com。并且不要认为托管在wordpress.com 上的网站能够使用插件。尽管如此,我还是会试一试。扣留赏金以防有人提出更好的解决方案。 :)
    • 你是如何在 localhost 上使用 wordpress.com 的?我还没有真正使用过 wordpress.com...
    • 我下载了 wordpress 以在我的本地主机上运行,​​只是为了主题。完成后,我会将主题推送到 wordpress.com
    • 由于 WordPress.com 的技术基础架构的设计方式,我们无法支持在我们的服务上上传自定义 WordPress 主题。 en.support.wordpress.com/themes/adding-new-themes
    • @parzival WP.com 不接受自定义主题或插件,您只能获得服务提供的内容。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多