本文整理汇总了PHP中oauth_client_class类的典型用法代码示例。如果您正苦于以下问题:PHP oauth_client_class类的具体用法?PHP oauth_client_class怎么用?PHP oauth_client_class使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了oauth_client_class类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: oauth_client_class
<?php
/*
* login_with_yandex.php
*
* @(#) $Id: login_with_yandex.php,v 1.1 2014/08/26 03:46:11 mlemos Exp $
*
*/
/*
* Get the http.php file from http://www.phpclasses.org/httpclient
*/
require 'http.php';
require 'oauth_client.php';
$client = new oauth_client_class();
$client->server = 'Yandex';
$client->debug = true;
$client->debug_http = true;
$client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_yandex.php';
$client->client_id = '';
$application_line = __LINE__;
$client->client_secret = '';
if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) {
die('Please go to Yandex developer applications page ' . 'https://oauth.yandex.com/client/new , create a new application ' . 'and in the line ' . $application_line . ' set the client_id to Application ID and client_secret with Application password. ' . 'The callback URL must be ' . $client->redirect_uri);
}
/* API permissions
*/
$client->scope = '';
if ($success = $client->Initialize()) {
if ($success = $client->Process()) {
if (strlen($client->authorization_error)) {
$client->error = $client->authorization_error;
示例2: define
// retreive information from user based on scope/permission
define("SCOPE", 'https://www.googleapis.com/auth/userinfo.email ' . 'https://www.googleapis.com/auth/userinfo.profile');
/* logout both from Google and your site **/
define("LOGOUT_URL", "https://www.google.com/accounts/Logout?continue=https://appengine.google.com/_ah/logout?continue=" . urlencode("http://localhost/TOMO2Project_Materialize/Card-2/card-2.php"));
?>
/* Add login URL in index.php */
<a class="btn btn-block btn-social btn-google-plus" href="index.php">
<i class="fa fa-google-plus"></i> Login with Google
</a>
<?php
require 'http.php';
require 'oauth_client.php';
require 'config.php';
$client = new oauth_client_class();
// set the offline access only if you need to call an API
// when the user is not present and the token may expire
$client->offline = FALSE;
$client->debug = false;
$client->debug_http = true;
$client->redirect_uri = REDIRECT_URL;
$client->client_id = CLIENT_ID;
$application_line = __LINE__;
$client->client_secret = CLIENT_SECRET;
if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) {
die('Please go to Google APIs console page ' . 'http://code.google.com/apis/console in the API access tab, ' . 'create a new client ID, and in the line ' . $application_line . ' set the client_id to Client ID and client_secret with Client Secret. ' . 'The callback URL must be ' . $client->redirect_uri . ' but make sure ' . 'the domain is valid and can be resolved by a public DNS.');
}
/* API permissions
*/
$client->scope = SCOPE;
示例3: the_champ_connect
/**
* Check querystring variables
*/
function the_champ_connect()
{
global $theChampLoginOptions;
// verify email
if (isset($_GET['SuperSocializerKey']) && ($verificationKey = trim(esc_attr($_GET['SuperSocializerKey']))) != '') {
$users = get_users('meta_key=thechamp_key&meta_value=' . $verificationKey);
if (count($users) > 0 && isset($users[0]->ID)) {
delete_user_meta($users[0]->ID, 'thechamp_key');
// update password and send email
$password = wp_generate_password();
wp_update_user(array('ID' => $users[0]->ID, 'user_pass' => $password));
the_champ_password_email($users[0]->ID, $password);
wp_redirect(home_url() . '?SuperSocializerVerified=1');
die;
}
}
// Instagram auth
if (isset($_GET['SuperSocializerInstaToken']) && $_GET['SuperSocializerInstaToken'] != '') {
$instaAuthUrl = 'https://api.instagram.com/v1/users/self?access_token=' . trim(esc_attr($_GET['SuperSocializerInstaToken']));
$response = wp_remote_get($instaAuthUrl, array('timeout' => 15));
if (!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']) {
$body = json_decode(wp_remote_retrieve_body($response));
if (is_object($body->data) && isset($body->data) && isset($body->data->id)) {
$redirection = isset($_GET['super_socializer_redirect_to']) && $_GET['super_socializer_redirect_to'] != '' ? esc_attr($_GET['super_socializer_redirect_to']) : '';
$response = the_champ_user_auth($body->data, 'instagram', $redirection);
if (is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')) {
$redirectTo = esc_attr(the_champ_get_login_redirection_url($redirection, true));
} elseif (isset($response['message']) && $response['message'] == 'linked') {
$redirectTo = $redirection . (strpos($redirection, '?') !== false ? '&' : '?') . 'linked=1';
} elseif (isset($response['message']) && $response['message'] == 'not linked') {
$redirectTo = $redirection . (strpos($redirection, '?') !== false ? '&' : '?') . 'linked=0';
} elseif (isset($response['url']) && $response['url'] != '') {
$redirectTo = $response['url'];
} else {
$redirectTo = esc_attr(the_champ_get_login_redirection_url($redirection));
}
the_champ_close_login_popup($redirectTo);
}
}
}
// send request to Xing
if (isset($_GET['SuperSocializerAuth']) && $_GET['SuperSocializerAuth'] == 'Xing') {
session_start();
if (!isset($_GET['oauth_token']) && isset($_SESSION['OAUTH_ACCESS_TOKEN'])) {
unset($_SESSION['OAUTH_ACCESS_TOKEN']);
}
if (isset($theChampLoginOptions['xing_ck']) && $theChampLoginOptions['xing_ck'] != '' && isset($theChampLoginOptions['xing_cs']) && $theChampLoginOptions['xing_cs'] != '') {
$xingClient = new oauth_client_class();
$xingClient->debug = 0;
$xingClient->debug_http = 1;
$xingClient->server = 'XING';
$xingClient->redirect_uri = site_url() . '/index.php?SuperSocializerAuth=Xing&super_socializer_redirect_to=' . esc_attr(str_replace(array('http://', 'https://'), '', urldecode($_GET['super_socializer_redirect_to'])));
$xingClient->client_id = $theChampLoginOptions['xing_ck'];
$xingClient->client_secret = $theChampLoginOptions['xing_cs'];
if ($success = $xingClient->Initialize()) {
if ($success = $xingClient->Process()) {
if (strlen($xingClient->access_token)) {
$success = $xingClient->CallAPI('https://api.xing.com/v1/users/me', 'GET', array(), array('FailOnAccessError' => true), $xingResponse);
}
}
$success = $xingClient->Finalize($success);
}
if ($xingClient->exit) {
die('exit');
}
if ($success) {
if (isset($xingResponse->users) && is_array($xingResponse->users) && isset($xingResponse->users[0]->id)) {
$xingRedirect = the_champ_get_http() . esc_attr($_GET['super_socializer_redirect_to']);
$response = the_champ_user_auth($xingResponse->users[0], 'xing', $xingRedirect);
if (is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')) {
$redirectTo = esc_attr(the_champ_get_login_redirection_url($xingRedirect, true));
} elseif (isset($response['message']) && $response['message'] == 'linked') {
$redirectTo = $xingRedirect . (strpos($xingRedirect, '?') !== false ? '&' : '?') . 'linked=1';
} elseif (isset($response['message']) && $response['message'] == 'not linked') {
$redirectTo = $xingRedirect . (strpos($xingRedirect, '?') !== false ? '&' : '?') . 'linked=0';
} elseif (isset($response['url']) && $response['url'] != '') {
$redirectTo = $response['url'];
} else {
$redirectTo = esc_attr(the_champ_get_login_redirection_url($xingRedirect));
}
the_champ_close_login_popup($redirectTo);
}
} else {
echo 'Error:' . $xingClient->error;
die;
}
}
}
// send request to twitter
if (isset($_GET['SuperSocializerAuth']) && $_GET['SuperSocializerAuth'] == 'Twitter') {
if (isset($theChampLoginOptions['twitter_key']) && $theChampLoginOptions['twitter_key'] != '' && isset($theChampLoginOptions['twitter_secret']) && $theChampLoginOptions['twitter_secret'] != '') {
/* Build TwitterOAuth object with client credentials. */
$connection = new TwitterOAuth($theChampLoginOptions['twitter_key'], $theChampLoginOptions['twitter_secret']);
/* Get temporary credentials. */
$requestToken = $connection->getRequestToken(site_url() . '/index.php');
if ($connection->http_code == 200) {
// generate unique ID
//.........这里部分代码省略.........
示例4: oauth_client_class
<?php
/*
* login_with_eventful.php
*
* @(#) $Id: login_with_eventful.php,v 1.3 2014/07/29 22:18:45 mlemos Exp $
*
*/
/*
* Get the http.php file from http://www.phpclasses.org/httpclient
*/
require 'http.php';
require 'oauth_client.php';
$client = new oauth_client_class();
$client->debug = 1;
$client->debug_http = 1;
$client->server = 'Eventful';
$client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_eventful.php';
$client->client_id = '';
$application_line = __LINE__;
$client->client_secret = '';
$application_key = '';
$account = '';
if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) {
die('Please go to Eventful API request key page http://api.eventful.com/keys/new , ' . 'create an application, and in the line ' . $application_line . ' set the client_id to oAuth Consumer Key and client_secret with oAuth Consumer Secret. ' . 'The Callback URL must be ' . $client->redirect_uri);
}
if ($success = $client->Initialize()) {
if ($success = $client->Process()) {
if (strlen($client->access_token)) {
$success = $client->CallAPI('http://api.evdb.com/rest/users/get', 'GET', array('id' => $account, 'app_key' => $application_key), array('FailOnAccessError' => true), $user);
}
示例5: oauth_client_class
<?php
/*
* login_with_withings.php
*
* @(#) $Id: login_with_withings.php,v 1.1 2014/01/26 05:07:10 mlemos Exp $
*
*/
/*
* Get the http.php file from http://www.phpclasses.org/httpclient
*/
require 'http.php';
require 'oauth_client.php';
$client = new oauth_client_class();
$client->debug = false;
$client->debug_http = true;
$client->server = 'Withings';
$client->redirect_uri = 'https://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_withings.php';
$client->client_id = '';
$application_line = __LINE__;
$client->client_secret = '';
if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) {
die('Please go to Withings Apps page https://oauth.withings.com/en/partner/add , ' . 'create an application, and in the line ' . $application_line . ' set the client_id to API key and client_secret with API secret. ' . 'The Callback URL must be ' . $client->redirect_uri) . '.';
}
if ($success = $client->Initialize()) {
if ($success = $client->Process()) {
if (strlen($client->access_token)) {
$success = $client->CallAPI('http://wbsapi.withings.net/user?action=getbyuserid&userid=0', 'GET', array(), array('FailOnAccessError' => true, 'ResponseContentType' => 'application/json'), $user);
}
}
$success = $client->Finalize($success);
示例6: dirname
<?php
require dirname(__FILE__) . '/../fb/http.php';
require dirname(__FILE__) . '/../fb/oauth_client.php';
$client = new oauth_client_class();
$client->debug = false;
$client->debug_http = false;
$client->server = 'Facebook';
$client->redirect_uri = 'http://v2.l4g.pl/lab/fbLoginOK.php';
$client->client_id = '134526290051121';
$application_line = __LINE__;
$client->client_secret = '8aef0e23031a9964381d8035fdf966c4';
$client->scope = 'email,publish_actions,user_friends,user_posts';
if ($success = $client->Initialize()) {
if ($success = $client->Process()) {
if (strlen($client->access_token)) {
$success = $client->CallAPI('https://graph.facebook.com/v2.3/me', 'GET', array(), array('FailOnAccessError' => true), $user);
$client->CallAPI('https://graph.facebook.com/v2.5/naglowki/feed?fields=message,full_picture', 'GET', array(), array('FailOnAccessError' => true), $fanpageData);
}
}
}
$data = array();
$data['source'] = 'Facebook';
if ($success) {
$data['status'] = 'OK';
if ($user->gender == 'male') {
$user->genderPL = 'Mężczyzna';
} else {
$user->genderPL = 'Kobieta';
}
$data['userData'] = $user;
示例7: oauth_client_class
<?php
/*
* login_with_runkeeper.php
*
* @(#) $Id: login_with_runkeeper.php,v 1.1 2014/05/15 08:29:50 mlemos Exp $
*
*/
/*
* Get the http.php file from http://www.phpclasses.org/httpclient
*/
require 'http.php';
require 'oauth_client.php';
$client = new oauth_client_class();
$client->server = 'RunKeeper';
$client->debug = false;
$client->debug_http = true;
$client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_runkeeper.php';
$client->client_id = '';
$application_line = __LINE__;
$client->client_secret = '';
if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) {
die('Please register a new RunKeeper application in ' . 'http://runkeeper.com/partner/applications/register , and in the line ' . $application_line . ' set the client_id to Client ID and ' . 'client_secret with Client Secret. ' . 'The callback URL must be ' . $client->redirect_uri . ' but make sure ' . 'it is a secure URL (https://).');
}
/* API permissions, empty is the default for this application
*/
$client->scope = '';
if ($success = $client->Initialize()) {
if ($success = $client->Process()) {
if (strlen($client->authorization_error)) {
$client->error = $client->authorization_error;
示例8: Dropbox
public static function Dropbox($oTenant)
{
$bResult = false;
$oUser = null;
$bDropboxAllow = $oTenant->SocialDropboxAllow;
$sDropboxId = $oTenant->SocialDropboxKey;
$sDropboxSecret = $oTenant->SocialDropboxSecret;
$sRedirectUrl = rtrim(\MailSo\Base\Http::SingletonInstance()->GetFullUrl(), '\\/ ') . '/?dropbox';
if (!strpos($sRedirectUrl, '://localhost')) {
$sRedirectUrl = str_replace('http:', 'https:', $sRedirectUrl);
}
if ($bDropboxAllow) {
require PSEVEN_APP_ROOT_PATH . 'libraries/OAuthClient/http.php';
require PSEVEN_APP_ROOT_PATH . 'libraries/OAuthClient/oauth_client.php';
$oClient = new \oauth_client_class();
$oClient->debug = self::$Debug;
$oClient->debug_http = self::$Debug;
$oClient->server = 'Dropbox2';
$oClient->redirect_uri = $sRedirectUrl;
$oClient->client_id = $sDropboxId;
$application_line = __LINE__;
$oClient->client_secret = $sDropboxSecret;
$oClient->configuration_file = PSEVEN_APP_ROOT_PATH . 'libraries/OAuthClient/' . $oClient->configuration_file;
if (strlen($oClient->client_id) == 0 || strlen($oClient->client_secret) == 0) {
$bResult = false;
exit('Please go to Dropbox Apps page https://www.dropbox.com/developers/apps , ' . 'create an application, and in the line ' . $application_line . ' set the client_id to Consumer key and client_secret with Consumer secret. ' . 'The Callback URL must be ' . $oClient->redirect_uri) . ' Make sure this URL is ' . 'not in a private network and accessible to the Dropbox site.';
}
if ($success = $oClient->Initialize()) {
if ($success = $oClient->Process()) {
if (strlen($oClient->access_token)) {
$success = $oClient->CallAPI('https://api.dropbox.com/1/account/info', 'GET', array(), array('FailOnAccessError' => true), $oUser);
}
}
$success = $oClient->Finalize($success);
}
if ($oClient->exit) {
$bResult = false;
exit;
}
if ($success && $oUser) {
// if you need re-ask user for permission
//$oClient->ResetAccessToken();
$aSocial = array('type' => 'dropbox', 'id' => $oUser->uid, 'name' => $oUser->display_name, 'email' => isset($oUser->email) ? $oUser->email : '', 'access_token' => $oClient->access_token);
\CApi::Log('social_user_dropbox');
\CApi::LogObject($oUser);
$bResult = $aSocial;
} else {
$bResult = false;
$oClient->ResetAccessToken();
self::_socialError($oClient->error, 'dropbox');
}
}
return $bResult;
}
示例9: oauth_client_class
<?php
/*
* login_with_flickr.php
*
* @(#) $Id: login_with_flickr.php,v 1.4 2013/07/31 11:48:04 mlemos Exp $
*
*/
/*
* Get the http.php file from http://www.phpclasses.org/httpclient
*/
require 'http.php';
require 'oauth_client.php';
$client = new oauth_client_class();
$client->debug = 0;
$client->debug_http = 1;
$client->server = 'Flickr';
$client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_flickr.php';
$client->client_id = '';
$application_line = __LINE__;
$client->client_secret = '';
if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) {
die('Please go to Flickr Apps page http://www.flickr.com/services/apps/create/ , ' . 'create an application, and in the line ' . $application_line . ' set the client_id to Key and client_secret with Secret.');
}
$client->scope = 'read';
// 'read', 'write' or 'delete'
if ($success = $client->Initialize()) {
if ($success = $client->Process()) {
if (strlen($client->access_token)) {
$success = $client->CallAPI('http://api.flickr.com/services/rest/', 'GET', array('method' => 'flickr.test.login', 'format' => 'json', 'nojsoncallback' => '1'), array('FailOnAccessError' => true), $user);
}
示例10: oauth_client_class
<?php
/*
* login_with_fitbit.php
*
* @(#) $Id: login_with_fitbit.php,v 1.2 2013/07/31 11:48:04 mlemos Exp $
*
*/
/*
* Get the http.php file from http://www.phpclasses.org/httpclient
*/
require 'http.php';
require 'oauth_client.php';
$client = new oauth_client_class();
$client->debug = 1;
$client->debug_http = 1;
$client->server = 'Fitbit';
$client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_fitbit.php';
$client->client_id = '';
$application_line = __LINE__;
$client->client_secret = '';
if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) {
die('Please go to Fitbit application registration page https://dev.fitbit.com/apps/new , ' . 'create an application, and in the line ' . $application_line . ' set the client_id to Consumer key and client_secret with Consumer secret. ' . 'The Callback URL must be ' . $client->redirect_uri) . ' Make sure this URL is ' . 'not in a private network and accessible to the Fitbit site.';
}
if ($success = $client->Initialize()) {
if ($success = $client->Process()) {
if (strlen($client->access_token)) {
$success = $client->CallAPI('https://api.fitbit.com/1/user/-/profile.json', 'GET', array(), array('FailOnAccessError' => true), $user);
}
}
$success = $client->Finalize($success);
示例11: oauth_client_class
* OAuth_solicitado: Indica el tipo de servicio OAuth que debe ser llamado.
* Permite por ahora los valores (22): Google, Facebook, LinkedIn, Instagram, Dropbox, Microsoft (Live), Flickr, Twitter, Foursquare, XING, Salesforce, Bitbucket, Yahoo, Box, Disqus, Eventful, SurveyMonkey, RightSignature, Fitbit, ScoopIt, Tumblr, StockTwits
Salida:
Redireccion del usuario a la pagina de login del proveedor de autenticacion , quien a su vez redireccionara al usuario segun el resultado
Ver tambien:
<Iniciar_login>
*/
if (@$PCO_WSId == "autenticacion_oauth") {
require 'inc/http/http.php';
// Incluye funciones del cliente HTTP para conexiones desde PHP
require 'inc/oauth/oauth_client.php';
// Incluye las librerias del modulo OAuth 1.0 y 2.0
// Inicia la conexion correspondiente
$client = new oauth_client_class();
// Define el servicio a llamar segun el recibido
$OAuth_servicio = $OAuthSrv;
// Google
if ($OAuth_servicio == 'Google') {
$OAuth_URIRedireccion = $APIGoogle_RedirectUri;
$OAuth_IDCliente = $APIGoogle_ClientId;
$OAuth_SecretoCliente = $APIGoogle_ClientSecret;
$OAuth_Mensaje = "Vaya a APIs de Google http://code.google.com/apis/console y cree un nuevo ID de cliente, Secreto y URI de redireccion.";
$OAuth_Alcance = 'https://www.googleapis.com/auth/userinfo.email ' . 'https://www.googleapis.com/auth/userinfo.profile';
$OAuth_Depuracion = false;
$OAuth_DepuracionHttp = true;
$OAuth_Offline = false;
}
// Facebook
if ($OAuth_servicio == 'Facebook') {
示例12: oauth_client_class
<?php
/*
* login_with_salesforce.php
*
* @(#) $Id: login_with_salesforce.php,v 1.2 2013/07/31 11:48:04 mlemos Exp $
*
*/
/*
* Get the http.php file from http://www.phpclasses.org/httpclient
*/
require 'http.php';
require 'oauth_client.php';
$client = new oauth_client_class();
$client->server = 'Salesforce';
$client->debug = true;
$client->debug_http = true;
$client->redirect_uri = 'https://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_salesforce.php';
$client->client_id = '';
$application_line = __LINE__;
$client->client_secret = '';
if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) {
die('Please login with your Salesforce developer account, click on the' . ' Setup link, then click on the Develop link, then click on the ' . 'Remote Access link, create a new connected app, and in the line ' . $application_line . ' set the client_id to Consumer key and ' . 'client_secret with Consumer Secret. ' . 'The callback URL must be ' . $client->redirect_uri . ' but make sure ' . 'it is a secure URL (https://).');
}
/* API permissions, empty is the default for this application
*/
$client->scope = '';
if ($success = $client->Initialize()) {
if ($success = $client->Process()) {
if (strlen($client->authorization_error)) {
$client->error = $client->authorization_error;
示例13: oauth_client_class
<?php
/*
* login_with_reddit.php
*
* @(#) $Id: login_with_reddit.php,v 1.1 2014/01/11 12:07:18 mlemos Exp $
*
*/
/*
* Get the http.php file from http://www.phpclasses.org/httpclient
*/
require 'http.php';
require 'oauth_client.php';
$client = new oauth_client_class();
$client->server = 'Reddit';
// set the offline access only if you need to call an API
// when the user is not present and the token may expire
$client->offline = true;
$client->debug = false;
$client->debug_http = true;
$client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_reddit.php';
$client->client_id = '';
$application_line = __LINE__;
$client->client_secret = '';
if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) {
die('Please go to Reddit preferences and apps page ' . 'https://ssl.reddit.com/prefs/apps , create a new application,' . ' and in the line ' . $application_line . ' set the client_id to' . ' application id below the title' . ' and client_secret with secret. ' . 'The callback URL must be ' . $client->redirect_uri);
}
/* API permissions
*/
$client->scope = 'identity';
if ($success = $client->Initialize()) {
示例14: oauth_client_class
<?php
/*
* login_with_stocktwits.php
*
* @(#) $Id: login_with_stocktwits.php,v 1.2 2013/07/31 11:48:04 mlemos Exp $
*
*/
/*
* Get the http.php file from http://www.phpclasses.org/httpclient
*/
require 'http.php';
require 'oauth_client.php';
$client = new oauth_client_class();
$client->server = 'StockTwits';
$client->debug = true;
$client->debug_http = true;
$client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_stocktwits.php';
$client->client_id = '';
$application_line = __LINE__;
$client->client_secret = '';
if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) {
die('Please go to StockTwits new application page ' . 'http://stocktwits.com/developers/apps/new and in the line ' . $application_line . ' set the client_id to Consumer key and client_secret with Consumer secret. ' . 'The site domain must have the same domain of ' . $client->redirect_uri);
}
/* API permissions
*/
$client->scope = 'read,watch_lists,publish_messages,publish_watch_lists,direct_messages,follow_users,follow_stocks';
if ($success = $client->Initialize()) {
if ($success = $client->Process()) {
if (strlen($client->authorization_error)) {
$client->error = $client->authorization_error;
示例15: oauth_client_class
<?php
/*
* login_with_bitly.php
*
* @(#) $Id: login_with_bitly.php,v 1.1 2014/05/15 04:06:17 mlemos Exp $
*
*/
/*
* Get the http.php file from http://www.phpclasses.org/httpclient
*/
require 'http.php';
require 'oauth_client.php';
$client = new oauth_client_class();
$client->server = 'Bitly';
$client->debug = false;
$client->debug_http = true;
$client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_bitly.php';
$client->client_id = '';
$application_line = __LINE__;
$client->client_secret = '';
if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) {
die('Please create a Bitly application in ' . 'https://bitly.com/a/oauth_apps , and in the line ' . $application_line . ' set the client_id to Client ID and ' . 'client_secret with Client Secret. ' . 'The callback URL must be ' . $client->redirect_uri . ' but make sure ' . 'it is a secure URL (https://).');
}
/* API permissions, empty is the default for this application
*/
$client->scope = '';
if ($success = $client->Initialize()) {
if ($success = $client->Process()) {
if (strlen($client->authorization_error)) {
$client->error = $client->authorization_error;