PHP Класс SaeTOAuthV2, libweibo

授权机制说明请大家参考微博开放平台文档:{@link http://open.weibo.com/wiki/Oauth2}
Автор: Elmer Zhang
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$access_token
$boundary boundary of multipart
$client_id
$client_secret
$connecttimeout Set connect timeout.
$debug print the debug info
$decode_json Decode returned json data.
$format Respons format.
$host Set up the API root URL.
$http_code Contains the last HTTP status code returned.
$http_info Contains the last HTTP headers returned.
$refresh_token
$ssl_verifypeer Verify SSL Cert.
$timeout Set timeout default.
$url Contains the last API call.
$useragent Set the useragnet.

Открытые методы

Метод Описание
__construct ( $client_id, $client_secret, $access_token = NULL, $refresh_token = NULL ) construct WeiboOAuth object
accessTokenURL ( )
authorizeURL ( )
base64decode ( $str )
build_http_query_multi ( $params )
delete ( $url, $parameters = [] ) : mixed DELTE wrapper for oAuthReqeust.
get ( $url, $parameters = [] ) : mixed GET wrappwer for oAuthRequest.
getAccessToken ( string $type = 'code', array $keys ) : array access_token接口
getAuthorizeURL ( string $url, string $response_type = 'code', string $state = NULL, string $display = NULL ) : array authorize接口
getHeader ( $ch, $header ) : integer Get the header info to store.
getTokenFromArray ( array $arr ) : array 从数组中读取access_token和refresh_token 常用于从Session或Cookie中读取token,或通过Session/Cookie中是否存有token判断登录状态。
getTokenFromJSSDK ( ) : array 读取jssdk授权信息,用于和jssdk的同步登录
http ( $url, $method, $postfields = NULL, $headers = [] ) : string Make an HTTP request
oAuthRequest ( $url, $method, $parameters, $multi = false ) : string Format and sign an OAuth / API request
parseSignedRequest ( string $signed_request ) : array 解析 signed_request
post ( $url, $parameters = [], $multi = false ) : mixed POST wreapper for oAuthRequest.

Описание методов

__construct() публичный Метод

construct WeiboOAuth object
public __construct ( $client_id, $client_secret, $access_token = NULL, $refresh_token = NULL )

accessTokenURL() публичный Метод

public accessTokenURL ( )

authorizeURL() публичный Метод

public authorizeURL ( )

base64decode() публичный Метод

public base64decode ( $str )

build_http_query_multi() публичный статический Метод

public static build_http_query_multi ( $params )

delete() публичный Метод

DELTE wrapper for oAuthReqeust.
public delete ( $url, $parameters = [] ) : mixed
Результат mixed

get() публичный Метод

GET wrappwer for oAuthRequest.
public get ( $url, $parameters = [] ) : mixed
Результат mixed

getAccessToken() публичный Метод

对应API:{@link http://open.weibo.com/wiki/OAuth2/access_token OAuth2/access_token}
public getAccessToken ( string $type = 'code', array $keys ) : array
$type string 请求的类型,可以为:code, password, token
$keys array 其他参数: - 当$type为code时: array('code'=>..., 'redirect_uri'=>...) - 当$type为password时: array('username'=>..., 'password'=>...) - 当$type为token时: array('refresh_token'=>...)
Результат array

getAuthorizeURL() публичный Метод

对应API:{@link http://open.weibo.com/wiki/Oauth2/authorize Oauth2/authorize}
public getAuthorizeURL ( string $url, string $response_type = 'code', string $state = NULL, string $display = NULL ) : array
$url string 授权后的回调地址,站外应用需与回调地址一致,站内应用需要填写canvas page的地址
$response_type string 支持的值包括 code 和token 默认值为code
$state string 用于保持请求和回调的状态。在回调时,会在Query Parameter中回传该参数
$display string 授权页面类型 可选范围: - default 默认授权页面 - mobile 支持html5的手机 - popup 弹窗授权页 - wap1.2 wap1.2页面 - wap2.0 wap2.0页面 - js js-sdk 专用 授权页面是弹窗,返回结果为js-sdk回掉函数 - apponweibo 站内应用专用,站内应用不传display参数,并且response_type为token时,默认使用改display.授权后不会返回access_token,只是输出js刷新站内应用父框架
Результат array

getHeader() публичный Метод

Get the header info to store.
public getHeader ( $ch, $header ) : integer
Результат integer

getTokenFromArray() публичный Метод

从数组中读取access_token和refresh_token 常用于从Session或Cookie中读取token,或通过Session/Cookie中是否存有token判断登录状态。
public getTokenFromArray ( array $arr ) : array
$arr array 存有access_token和secret_token的数组
Результат array 成功返回array('access_token'=>'value', 'refresh_token'=>'value'); 失败返回false

getTokenFromJSSDK() публичный Метод

读取jssdk授权信息,用于和jssdk的同步登录
public getTokenFromJSSDK ( ) : array
Результат array 成功返回array('access_token'=>'value', 'refresh_token'=>'value'); 失败返回false

http() публичный Метод

Make an HTTP request
public http ( $url, $method, $postfields = NULL, $headers = [] ) : string
Результат string API results

oAuthRequest() публичный Метод

Format and sign an OAuth / API request
public oAuthRequest ( $url, $method, $parameters, $multi = false ) : string
Результат string

parseSignedRequest() публичный Метод

解析 signed_request
public parseSignedRequest ( string $signed_request ) : array
$signed_request string 应用框架在加载iframe时会通过向Canvas URL post的参数signed_request
Результат array

post() публичный Метод

POST wreapper for oAuthRequest.
public post ( $url, $parameters = [], $multi = false ) : mixed
Результат mixed

Описание свойств

$access_token публичное свойство

public $access_token

$boundary публичное статическое свойство

boundary of multipart
public static $boundary

$client_id публичное свойство

public $client_id

$client_secret публичное свойство

public $client_secret

$connecttimeout публичное свойство

Set connect timeout.
public $connecttimeout

$debug публичное свойство

print the debug info
public $debug

$decode_json публичное свойство

Decode returned json data.
public $decode_json

$format публичное свойство

Respons format.
public $format

$host публичное свойство

Set up the API root URL.
public $host

$http_code публичное свойство

Contains the last HTTP status code returned.
public $http_code

$http_info публичное свойство

Contains the last HTTP headers returned.
public $http_info

$refresh_token публичное свойство

public $refresh_token

$ssl_verifypeer публичное свойство

Verify SSL Cert.
public $ssl_verifypeer

$timeout публичное свойство

Set timeout default.
public $timeout

$url публичное свойство

Contains the last API call.
public $url

$useragent публичное свойство

Set the useragnet.
public $useragent