PHP extension-OAuth

Source: Internet
Author: User
PHP Extension Web Service-OAuth

I. Overview and installation

This extension provides binding between the OAuth consumer and the provider. OAuth is an authorization protocol built on HTTP that allows applications to securely access data without storing user names and passwords.

PECL/oauth requires PHP 5.1 or later, and ext/hash and ext/pcre.

If you select PECL/oauth during building, you can choose libcurl. If you use libcurl for configuration, you must build HTTPS support.

Information about installing this PECL extension can be found in the installation section named PECL extension in the manual.

II. example

 EnableDebug (); if (! Isset ($ _ GET ['Oss _ token']) &! $ _ SESSION ['state']) {$ request_token_info = $ oauth-> getRequestToken ($ req_url ); $ _ SESSION ['secret'] = $ request_token_info ['auth _ token_secret ']; $ _ SESSION ['state'] = 1; header ('Location :'. $ authurl. '? Oauth_token = '. $ request_token_info ['Oss _ token']); exit;} else if ($ _ SESSION ['state'] = 1) {$ oauth-> setToken ($ _ GET ['auth _ token'], $ _ SESSION ['secret']); $ access_token_info = $ oauth-> getAccessToken ($ acc_url); $ _ SESSION ['state'] = 2; $ _ SESSION ['token'] = $ access_token_info ['Oss _ token']; $ _ SESSION ['secret'] = $ access_token_info ['Oss _ token_secret '];} $ oauth-> setToken ($ _ SESSION ['token'], $ _ SESSION ['s Ecret ']); $ oauth-> fetch ("$ api_url/user. json "); $ json = json_decode ($ oauth-> getLastResponse (); print_r ($ json);} catch (OAuthException $ E) {print_r ($ E) ;}?>

III. related functions

Oauth_get_sbs-generate a signature character base string

Oauth_urlencode-encode URI as RFC 3986 specification

IV. related classes and their member functions

OAuth class

OAuth ::__ construct-create an OAuth object

OAuth: :__ destruct-destructor

OAuth: disableDebug-disable detailed debugging

OAuth: disableRedirects-disable redirection

OAuth: disableSSLChecks-disable SSL check

OAuth: enableDebug-enable detailed debugging

OAuth: enableRedirects-enable redirection

OAuth: enableSSLChecks-enable SSL check

OAuth: fetch-get an OAuth protected resource

OAuth: generateSignature-generate a signature

OAuth: getAccessToken-get an access token

OAuth: getCAPath-get CA information

OAuth: getLastResponse-get the last response

OAuth: getLastResponseHeaders-get the header information of the last response

OAuth: getLastResponseInfo-get the HTTP information about the last response

OAuth: getRequestHeader-generate OAuth header information string signature

OAuth: getRequestToken-get a request token

OAuth: setAuthType-set authorization type

OAuth: setCAPath-set the CA path and information

OAuth: setNonce-set the current flag for subsequent requests

OAuth: setRequestEngine-set the target request engine

OAuth: setRSACertificate-set RSA certificate

OAuth: setSSLChecks-adjust the specific SSL request check

OAuth: setTimestamp-set the timestamp

OAuth: setToken-set the token and secret

OAuth: setVersion-set the OAuth version

OAuthProvider class

OAuthProvider: addRequiredParameter-add required parameters

OAuthProvider: callconsumerHandler-call the consumerNonceHandler callback function

OAuthProvider: callTimestampNonceHandler-call the timestampNonceHandler callback function.

OAuthProvider: calltokenHandler-call the tokenNonceHandler callback function.

OAuthProvider: checkOAuthRequest-check an oauth request

OAuthProvider ::__ construct-create an OAuthProvider object

OAuthProvider: consumerHandler-set the consumerHandler handle callback function

OAuthProvider: generateToken-generate a random token

OAuthProvider: is2LeggedEndpoint-is2LeggedEndpoint

OAuthProvider: isRequestTokenEndpoint-set isRequestTokenEndpoint

OAuthProvider: removeRequiredParameter-remove a required parameter

OAuthProvider: reportProblem-report problem

OAuthProvider: setParam-set a parameter

OAuthProvider: setRequestTokenPath-set the request token path

OAuthProvider: timestampNonceHandler-set the timestampNonceHandler handle callback function

OAuthProvider: tokenHandler-set the tokenHandler handle callback function

OAuthException class

OAuthException-OAuthException class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.