php 如何将 Facebook 相册集成到网站中?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5829477/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 22:36:48  来源:igfitidea点击:

How can I integrate Facebook photo album into website?

phpxmlfacebookfacebook-graph-apiphotos

提问by Nicekiwi

Possible Duplicate:
Facebook Api - how to access my photo album

可能重复:
Facebook Api - 如何访问我的相册

How can I display photos from a Facebook album inside a website?

如何在网站内显示 Facebook 相册中的照片?

回答by DannyKK

You can use the graph api to get the images in an album, like this: https://graph.facebook.com/ALBUM_ID/photosYou get an array containing all the images in that album. The array contains objects like this:

您可以使用图形 API 获取相册中的图像,如下所示: https://graph.facebook.com/ALBUM_ID/photos您将获得一个包含该相册中所有图像的数组。该数组包含如下对象:

"name": "hopes you're having a great weekend!",
         "picture": "http://photos-d.ak.fbcdn.net/hphotos-ak-snc1/5370_127826373305_40796308305_2373079_2781005_s.jpg",
         "source": "http://a4.sphotos.ak.fbcdn.net/hphotos-ak-snc1/5370_127826373305_40796308305_2373079_2781005_n.jpg",
         "height": 604,
         "width": 427,
         "images": [
            {
               "height": 604,
               "width": 427,
               "source": "http://a4.sphotos.ak.fbcdn.net/hphotos-ak-snc1/5370_127826373305_40796308305_2373079_2781005_n.jpg"
            },
            {
               "height": 254,
               "width": 180,
               "source": "http://photos-d.ak.fbcdn.net/hphotos-ak-snc1/5370_127826373305_40796308305_2373079_2781005_a.jpg"
            },
            {
               "height": 130,
               "width": 91,
               "source": "http://photos-d.ak.fbcdn.net/hphotos-ak-snc1/5370_127826373305_40796308305_2373079_2781005_s.jpg"
            },
            {
               "height": 106,
               "width": 75,
               "source": "http://photos-d.ak.fbcdn.net/hphotos-ak-snc1/5370_127826373305_40796308305_2373079_2781005_t.jpg"
            }
         ],

This is an example from the api documentation. You can use these image links directly, facebook even gives you different sizes for the gallery. Good luck.

这是 api 文档中的一个示例。您可以直接使用这些图片链接,Facebook 甚至会为您提供不同尺寸的图库。祝你好运。

回答by Flask

yes its possible: Here an example with Graph:

是的,它可能:这里有一个图形示例:

Photos: https://graph.facebook.com/98423808305(A photo from the Coca-Cola page)

照片:https: //graph.facebook.com/98423808305(来自可口可乐页面的照片)

Photo albums: https://graph.facebook.com/99394368305(Coca-Cola's wall photos)

相册:https: //graph.facebook.com/99394368305(可口可乐的墙上照片)

回答by Day Milovich

If you use self hosted domain with Wordpress, you can do it with these steps:

如果您在 Wordpress 中使用自托管域,则可以通过以下步骤进行:

Install and Activate Facebook Photo Fetcher for Wordpress

安装并激活适用于 Wordpress 的 Facebook Photo Fetcher

  1. Download the latest version of Facebook Photo Fetcher plugin for Wordpress http://wordpress.org/extend/plugins/facebook-photo-fetcher/
  2. Extract and activate the plugin via dashboard
  1. 下载适用于 Wordpress 的最新版 Facebook Photo Fetcher 插件 http://wordpress.org/extend/plugins/facebook-photo-fetcher/
  2. 通过仪表板提取并激活插件

Setting for your Facebook Photo Fetcher

为您的 Facebook Photo Fetcher 设置

  1. Settings > FB Photo Fetcher
  2. Click "Login to Facebook"
  3. Enter your information > Login > close the popup
  4. Grant Photo Permissions > Accept the permissions > Success!
  5. click "Save Facebook Session"
  1. 设置 > FB 照片提取器
  2. 点击“登录脸书”
  3. 输入您的信息 > 登录 > 关闭弹出窗口
  4. 授予照片权限 > 接受权限 > 成功!
  5. 单击“保存 Facebook 会话”

This plugin is successfully connected with your ID Facebook account.

此插件已成功连接到您的 ID Facebook 帐户。

Insert your Facebook Album into Post or Page in Wordpress */

将您的 Facebook 相册插入到 Wordpress 的帖子或页面中 */

  1. Search for Albums > it will open your album and get you album ID For Example, the album ID is: 123456789987654321 Create a new post or page in wordpress > use HTML editor not visual
  2. Insert this code:

    <!-- FBGallery 1234567890123456789 --> <!--/FBGallery -->
    

    Change 1234567890123456789 with your real facebook album ID.

  3. Save > see your page.

  1. 搜索相册 > 它将打开您的相册并获取您的相册 ID 例如,相册 ID 为:123456789987654321 在 wordpress 中创建一个新帖子或页面 > 使用 HTML 编辑器不可视
  2. 插入此代码:

    <!-- FBGallery 1234567890123456789 --> <!--/FBGallery -->
    

    将 1234567890123456789 更改为您真实的 Facebook 相册 ID。

  3. 保存 > 查看您的页面。

Demo: http://www.justin-klein.com/projects/facebook-photo-fetcher#demo

演示:http: //www.justin-klein.com/projects/facebook-photo-fetcher#demo

回答by Steve

You will need to manage the authentication firstly. If you are using the facebook php api and its your own photo album you can request permanent access

您首先需要管理身份验证。如果您使用的是 facebook php api 及其自己的相册,则可以请求永久访问

$facebook->getLoginUrl(array('req_perms' =>'user_photos friends_photos')); }

$facebook->getLoginUrl(array('req_perms' =>'user_photosfriends_photos')); }

Then after that you can make requests to the graph api such as http://graph.facebook.com/me/albums- your auth key will at the end of that request.

然后,您可以向图形 api 发出请求,例如http://graph.facebook.com/me/albums- 您的身份验证密钥将在该请求的末尾。