PHP 클래스 SaeTOAuthV2, libweibo

授权机制说明请大家参考微博开放平台文档:{@link http://open.weibo.com/wiki/Oauth2}
저자: Elmer Zhang
파일 보기 프로젝트 열기: xiaosier/libweibo 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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