【问题标题】:Getting automatic profile pics for users in php?在 php 中获取用户的自动配置文件图片?
【发布时间】:2011-11-07 07:34:00
【问题描述】:

我有一个需要与 facebook 个人资料图片匹配的名称列表,没有 access_token。 使用 http://graph.facebook.com/USERNAME/picture 获取图片似乎只有在用户有用户名的情况下才有效。

最好的方法是什么?

我还查看了 pipl.com,他们只需一个名字就可以非常轻松地获取 myspace 和 facebook 个人资料图片。

【问题讨论】:

    标签: php facebook api profile image


    【解决方案1】:

    如果您只有名称,则可以使用图形 API 进行搜索,但除非名称是唯一的,否则您可能会得到很多结果。

    https://graph.facebook.com/search?q=mark%20zuckerberg&type=user&access_token=...

    您可以使用任何访问令牌进行搜索,例如 Graph API explorer 提供给您的访问令牌。

    【讨论】:

    • 这很有帮助,但我怎样才能获得热门搜索结果的头像?
    • 但是我可以直接在 php 代码中执行此操作。无需手动传输用户 ID。感谢您的回复。
    【解决方案2】:

    您可以通过http://graph.facebook.com/USERNAME/picturehttp://graph.facebook.com/USERID/picture 的任何一种方式使用get this。

    【讨论】:

      【解决方案3】:

      好的,这是我想出的代码: 你输入某人的全名,它会得到一张个人资料图片,前提是你有一个访问令牌。

      <?php $fullname= get_the_title(); //gets users name
      $data = file_get_contents('https://graph.facebook.com/search?q='.urlencode($fullname).'&type=user&access_token=...'); //Querys FB ID from facebook graph api
      $lessdata = substr($data, strpos($data,'id":"') + 5); //Removes evrything before the start of the FB ID
      $fbid = substr($lessdata, 0, strpos($lessdata, '"')); // removes everything after the FB ID
      $fbimage = 'https://graph.facebook.com/'.$fbid.'/picture'; echo '<img src="'.$fbimage.'"/>' ?> 
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-11-07
        • 1970-01-01
        • 2019-04-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多