PHP 클래스 HttpSocketOauth, http_socket_oauth

The correct OAuth Authorization header is determined from the request params and then set in the $request['header']['Authorization'] param of the request array before passing it back to HttpSocket::request() to send the request and parse the response. So to trigger OAuth, add $request['auth']['method'] = 'OAuth' to your request. In addition, you'll need to add your consumer key in the $request['auth']['oauth_consumer_key'] and your consumer secret in the $request['auth']['oauth_consumer_secret'] param. These are given to you by the OAuth provider. And once you have them, $request['auth']['oauth_token'] and $request['auth']['oauth_token_secret'] params. Your OAuth provider may require you to send additional params too. Include them in the $request['auth'] array and they'll be passed on in the Authorization header and considered when signing the request.
저자: Neil Crookes ([email protected])
상속: extends HttpSocket
파일 보기 프로젝트 열기: neilcrookes/http_socket_oauth 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$defaults array Default OAuth parameters. These get merged into the $request['auth'] param.

공개 메소드들

메소드 설명
assocToNumericNameValue ( array $array ) : array Converts an associative array of name => value pairs to a numerically indexed array of array('name' => '', 'value' => '') elements.
authorizationHeader ( array $request ) : String Returns the OAuth Authorization Header string for a given request array.
authorizationHeaderParamEncode ( string $name, string $value ) : string Builds an Authorization header param string from the supplied name and value. See below for example:
parameterEncode ( string $param ) : string Encodes paramters as per the OAuth spec by utf 8 encoding the param (if it is not already utf 8 encoded) and then percent encoding it according to RFC3986
request ( array $request = [] ) : array Overrides HttpSocket::request() to handle cases where $request['auth']['method'] is 'OAuth'.
sortByNameThenByValue ( array $a, array $b ) : integer User defined function to lexically sort an array of array('name' => '', 'value' => '') elements by the value of the name key, and if they're the same, then by the value of the value key.

메소드 상세

assocToNumericNameValue() 공개 메소드

Converts an associative array of name => value pairs to a numerically indexed array of array('name' => '', 'value' => '') elements.
public assocToNumericNameValue ( array $array ) : array
$array array Associative array
리턴 array

authorizationHeader() 공개 메소드

This method is called by request but can also be called directly, which is useful if you need to get the OAuth Authorization Header string, such as when integrating with a service that uses OAuth Echo (Authorization Delegation) e.g. Twitpic. In this case you send a normal unauthenticated request to the service e.g. Twitpic along with 2 extra headers: - X-Auth-Service-Provider - effectively, this is the realm that identity delegation should be sent to - in the case of Twitter, just set this to https://api.twitter.com/1/account/verify_credentials.json; - X-Verify-Credentials-Authorization - Consumer should create all the OAuth parameters necessary so it could call https://api.twitter.com/1/account/verify_credentials.json using OAuth in the HTTP header (e.g. it should look like OAuth oauth_consumer_key="...", oauth_token="...", oauth_signature_method="...", oauth_signature="...", oauth_timestamp="...", oauth_nonce="...", oauth_version="...".
public authorizationHeader ( array $request ) : String
$request array As required by HttpSocket::request(). NOTE ONLY THE ARRAY TYPE OF REQUEST IS SUPPORTED
리턴 String

authorizationHeaderParamEncode() 공개 메소드

Builds an Authorization header param string from the supplied name and value. See below for example:
public authorizationHeaderParamEncode ( string $name, string $value ) : string
$name string E.g. 'oauth_signature_method'
$value string E.g. 'HMAC-SHA1'
리턴 string E.g. 'oauth_signature_method="HMAC-SHA1"'

parameterEncode() 공개 메소드

Encodes paramters as per the OAuth spec by utf 8 encoding the param (if it is not already utf 8 encoded) and then percent encoding it according to RFC3986
public parameterEncode ( string $param ) : string
$param string
리턴 string

request() 공개 메소드

Overrides HttpSocket::request() to handle cases where $request['auth']['method'] is 'OAuth'.
public request ( array $request = [] ) : array
$request array As required by HttpSocket::request(). NOTE ONLY THE ARRAY TYPE OF REQUEST IS SUPPORTED
리턴 array

sortByNameThenByValue() 공개 메소드

User defined function to lexically sort an array of array('name' => '', 'value' => '') elements by the value of the name key, and if they're the same, then by the value of the value key.
public sortByNameThenByValue ( array $a, array $b ) : integer
$a array Array with key for 'name' and one for 'value'
$b array Array with key for 'name' and one for 'value'
리턴 integer 1, 0 or -1 depending on whether a greater than b, less than or the same.

프로퍼티 상세

$defaults 공개적으로 프로퍼티

Default OAuth parameters. These get merged into the $request['auth'] param.
public array $defaults
리턴 array