graph api_与Facebook Graph API集成

本文介绍了如何使用Facebook的PHP SDK与Facebook Graph API进行集成,包括在Facebook上注册应用,使用SDK进行授权和交互,以及如何更新状态和上传照片。通过PHP SDK,可以轻松实现与Facebook的接口,实现网站的社交功能。
摘要由CSDN通过智能技术生成

graph api

Integrating with Facebook from PHP is easy with the help of Facebook’s PHP SDK and some HTTP libraries like Zend_Http_Client or PEAR HTTP_Request2. In this article I’ll show you how to get started using the Facebook PHP SDK. You’ll learn about the Facebook Graph API and create a Facebook application capable of updating your status message and uploading photos.

借助FacebookPHP SDK和一些HTTP库(例如Zend_Http_Client或PEAR HTTP_Request2),可以轻松地从PHP与Facebook集成。 在本文中,我将向您展示如何开始使用Facebook PHP SDK。 您将了解Facebook Graph API,并创建一个能够更新状态消息和上传照片的Facebook应用程序。

If you don’t have it already, you can clone or download the PHP SDK from GitHub. You’ll also need a verified Facebook account.

如果还没有,可以从GitHub克隆或下载PHP SDK 。 您还需要一个经过验证的Facebook帐户。

在Facebook上注册您的应用 (Registering your App on Facebook)

You first need to register your application on Facebook. Go to developers.facebook.com/apps and click the Create New App button at the top of the page.

您首先需要在Facebook上注册您的应用程序。 转到developers.facebook.com/apps ,然后单击页面顶部的“ 创建新应用”按钮。

The dialog that opens asks you for the name and a namespace for your application. App Display Name is the name for your application that will be shown to the users. App Namespace is the namespace your application will use for Open Graph and Canvas Page.

打开的对话框将询问您应用程序的名称和名称空间。 应用程序显示名称是将显示给用户的应用程序名称。 应用程序命名空间是您的应用程序将用于“打开图形”和“画布页面”的命名空间。

alt

After you register the application, you’ll be taken to the Basic Settings screen on which you need to specify how your app will integrate with Facebook:

注册该应用程序后,将转到“基本设置”屏幕,在该屏幕上需要指定您的应用程序如何与Facebook集成:

  • Website – The website option is used for adding social functionality to your website.

    网站 –网​​站选项用于向您的网站添加社交功能。

  • App on Facebook – This Facebook app option embeds your application within a Facebook Canvas page. The code is hosted on your servers, but executes within the context of a Facebook page, similar to an IFrame.

    Facebook上的应用程序–此Facebook应用程序选项将您的应用程序嵌入Facebook Canvas页面中。 该代码托管在您的服务器上,但在Facebook页面的上下文中执行,类似于IFrame。

  • Mobile Web – The mobile web option is similar to the Website integration option, although it’s intended for mobile sites.

    移动Web –移动Web选项类似于“网站集成”选项,尽管它适用于移动网站。

  • Native iOS/Android App – The native options allow you to integrate Facebook data in your iOS and Android applications.

    本机iOS / Android应用程序 –本机选项允许您将Facebook数据集成到iOS和Android应用程序中。

  • Page Tab – The tab option exposes your application as a Facebook page tab.

    页面选项卡 –选项卡选项将您的应用程序显示为Facebook页面选项卡。

For the purposes of this article I’ll use the website integration option. My application will be a stand-alone website, and after authorization Facebook will redirect the user to a specified URL. Select the check mark next to the option and enter the URL for your application’s entry page. Then be sure to click the Save Changes button at the bottom of the page.

就本文而言,我将使用网站集成选项。 我的应用程序将是一个独立的网站,经过授权,Facebook会将用户重定向到指定的URL。 选择选项旁边的复选标记,然后输入应用程序进入页面的URL。 然后确保单击页面底部的“ 保存更改”按钮。

You should also make a note of the App ID and App Secret values at the top of the page since you will need these valu

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值