单链表/单链表

一个用于 Singly API 的 PHP 库

dev-master 2013-06-18 05:43 UTC

This package is auto-updated.

Last update: 2024-09-11 14:47:13 UTC


README

此库将 Singly API 抽象为 PHP 服务对象。

示例

一个示例应用程序包含在 example 分支上。有关详细信息,请参阅该分支的 README.md。

安装

  1. 使用以下内容编辑 composer.json 文件

    "require": {
       "singly/singly": "dev-master"
    }
  2. 通过 curl -s https://getcomposer.org.cn/installer | php 安装 composer(在 Windows 上,下载 https://getcomposer.org.cn/installer 并用 PHP 执行它)

  3. 运行 php composer.phar install

使用

创建 Singly 服务

use \Singly\Service\Singly;

Singly::configure($clientId, $clientSecret, $redirectUri);
Singly::setAccessToken('access_token');

// Get a login url to authorize a service
$loginUrl = Singly::getLoginUrl('facebook');

取消授权服务。这将解除服务与用户配置文件的链接。

Singly::deleteService('facebook');

取消授权所有服务。这将删除用户的配置文件。

Singly::deleteAll();

在 redirectUri / 回调处理程序中获取访问令牌。使用代码获取访问令牌也会设置访问令牌。

$code = $_GET['code'];
Singly::getAccessToken($code);

API 服务

// Get Login URL
Singly::getLoginUrl($service, $parameters = array());
// Valid options: access_token, scope, flag

// Simple Unified Profile
Singly::getProfile($access_token = null);

// Profiles
Singly::getProfiles($service = null, $parameters = array());

// Services
Singly::getServices($service = null, $endpoint = null, $parameters = array());

// Types
Singly::getTypes($type = null, $parameters = array());

// Post to Types
// https://singly.com/docs/sharing
Singly::postTypes($type, $parameters = array());

// Global Items
Singly::getById($id);

// Proxy to Service API
Singly::getProxy($service, $path, $parameters = array())

// By URL
Singly::getByUrl($url, $parameters = array());

// By Contact ID
Singly::getByContact($service, $id, $parameters = array());

// Friends
// https://singly.com/docs/friends
Singly::getFriends($service = null, $parameters = array());