This class serves two main purposes: 1) Implement the OAuth protocol to retrieve a token from a server to authorize the access to an API on behalf of the current user. 2) Perform calls to a Web services API using a token previously obtained using this class or a token provided some other way by the Web services provider. Usage Regardless of your…
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md Initial commit Sep 10, 2014
cookie_oauth_client.php final-version Sep 10, 2014
database_oauth_client.php
http.php final-version Sep 10, 2014
login_with_37signals.php
login_with_amazon.php final-version Sep 10, 2014
login_with_bitbucket.php final-version Sep 10, 2014
login_with_bitly.php
login_with_box.php final-version Sep 10, 2014
login_with_buffer.php final-version Sep 10, 2014
login_with_copy.php final-version Sep 10, 2014
login_with_dailymotion.php final-version Sep 10, 2014
login_with_discogs.php final-version Sep 10, 2014
login_with_disqus.php
login_with_dropbox.php final-version Sep 10, 2014
login_with_etsy.php
login_with_eventful.php final-version Sep 10, 2014
login_with_facebook.php final-version Sep 10, 2014
login_with_fitbit.php final-version Sep 10, 2014
login_with_flickr.php
login_with_foursquare.php final-version Sep 10, 2014
login_with_github.php final-version Sep 10, 2014
login_with_google.php final-version Sep 10, 2014
login_with_instagram.php final-version Sep 10, 2014
login_with_linkedin.php
login_with_mail.ru.php final-version Sep 10, 2014
login_with_mavenlink.php
login_with_microsoft.php final-version Sep 10, 2014
login_with_odesk.php
login_with_rdio.php final-version Sep 10, 2014
login_with_reddit.php final-version Sep 10, 2014
login_with_rightsignature.php final-version Sep 10, 2014
login_with_runkeeper.php
login_with_salesforce.php
login_with_scoopit.php final-version Sep 10, 2014
login_with_stocktwits.php final-version Sep 10, 2014
login_with_surveymonkey.php final-version Sep 10, 2014
login_with_tumblr.php final-version Sep 10, 2014
login_with_twitter.php final-version Sep 10, 2014
login_with_vimeo.php final-version Sep 10, 2014
login_with_vk.php final-version Sep 10, 2014
login_with_withings.php
login_with_wordpress.php final-version Sep 10, 2014
login_with_xero.php final-version Sep 10, 2014
login_with_xing.php final-version Sep 10, 2014
login_with_yahoo.php final-version Sep 10, 2014
login_with_yandex.php final-version Sep 10, 2014
mysqli_login_with_google.php final-version Sep 10, 2014
mysqli_login_with_twitter.php
mysqli_oauth_client.php
mysqli_offline_access_to_google.php final-version Sep 10, 2014
mysqli_offline_access_to_twitter.php final-version Sep 10, 2014
oauth.png
oauth.sql final-version Sep 10, 2014
oauth_client.php final-version Sep 10, 2014
oauth_client_class.html
oauth_configuration.json
php-oauth-api.png final-version Sep 10, 2014
test_oauth_client.php final-version Sep 10, 2014

README.md

php-oauth-api

This class serves two main purposes: 1) Implement the OAuth protocol to retrieve a token from a server to authorize the access to an API on behalf of the current user. 2) Perform calls to a Web services API using a token previously obtained using this class or a token provided some other way by the Web services provider. Usage Regardless of your purposes, you always need to start calling the class Initialize function after initializing setup variables. After you are done with the class, always call the Finalize function at the end. This class supports either OAuth protocol versions 1.0, 1.0a and 2.0. It abstracts the differences between these protocol versions, so the class usage is the same independently of the OAuth version of the server. The class also provides built-in support to several popular OAuth servers, so you do not have to manually configure all the details to access those servers. Just set the server variable to configure the class to access one of the built-in supported servers. If you need to access one type of server that is not yet directly supported by the class, you need to configure it explicitly setting the variables: oauth_version, url_parameters, authorization_header, request_token_url, dialog_url, offline_dialog_url, append_state_to_redirect_uri and access_token_url. Before proceeding to the actual OAuth authorization process, you need to have registered your application with the OAuth server. The registration provides you values to set the variables client_id and client_secret. Some servers also provide an additional value to set the api_key variable. You also need to set the variables redirect_uri and scope before calling the Process function to make the class perform the necessary interactions with the OAuth server. The OAuth protocol involves multiple steps that include redirection to the OAuth server. There it asks permission to the current user to grant your application access to APIs on his/her behalf. When there is a redirection, the class will set the exit variable to 1. Then your script should exit immediately without outputting anything. When the OAuth access token is successfully obtained, the following variables are set by the class with the obtained values: access_token, access_token_secret, access_token_expiry, access_token_type. You may want to store these values to use them later when calling the server APIs. If there was a problem during OAuth authorization process, check the variable authorization_error to determine the reason. Once you get the access token, you can call the server APIs using the CallAPI function. Check the access_token_error variable to determine if there was an error when trying to to call the API. If for some reason the user has revoked the access to your application, you need to ask the user to authorize your application again. First you may need to call the function ResetAccessToken to reset the value of the access token that may be cached in session variables.