本文整理汇总了PHP中Authentication::ConnectTwitter方法的典型用法代码示例。如果您正苦于以下问题:PHP Authentication::ConnectTwitter方法的具体用法?PHP Authentication::ConnectTwitter怎么用?PHP Authentication::ConnectTwitter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Authentication
的用法示例。
在下文中一共展示了Authentication::ConnectTwitter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: header
<?php
require_once '../config/init.php';
if (!Session::Get('twitter_user')) {
header('Location: ../index.php');
}
$user_data = Session::Get('twitter_user');
if (isset($_POST['continue'])) {
$validator = new Validate();
if ($validator->AddValue('email', $_POST['email'])->AddPattern('email-unique')->Check()) {
$user_data['email'] = $_POST['email'];
Authentication::ConnectTwitter($user_data);
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body style="text-align:center;margin:auto;width:300px;">
<h2>Twitter doesn`t allow us to access your email account. Please enter your email adress to continue.</h2>
<form method="POST" action="">
<?php
if (Error::HasErrors()) {
?>
<div class="message-box"><!-- add your error class here -->
<ul>
<?php
foreach (Error::GetAll() as $key => $value) {
示例2: TwitterOAuth
} else {
if ($method == "twitter") {
require_once '../classes/vendor/twitter/twitteroauth.php';
$CONSUMER_KEY = Config::Get('social.twitter.id');
$CONSUMER_SECRET = Config::Get('social.twitter.secret');
$OAUTH_CALLBACK = Config::Get('base_url') . 'auth/connect.php?method=twitter';
if (isset($_GET['oauth_token']) && isset($_GET['oauth_verifier'])) {
$connection = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET, $_SESSION['request_token'], $_SESSION['request_token_secret']);
$access_token = @$connection->getAccessToken($_REQUEST['oauth_verifier']);
if (isset($access_token['oauth_token']) && isset($access_token['oauth_token_secret'])) {
$connection = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
$params = array();
$params['include_entities'] = 'false';
$content = $connection->get('account/verify_credentials', $params);
if ($content && isset($content->screen_name) && isset($content->name)) {
Authentication::ConnectTwitter(array('id' => $content->id, 'username' => $content->screen_name, 'fullname' => $content->name, 'picture' => $content->profile_image_url, 'location' => $content->location, 'about' => $content->description));
}
} else {
Error::Set('twitter', 'unexpectederror');
}
} else {
$connection = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET);
$request_token = @$connection->getRequestToken($OAUTH_CALLBACK);
if (isset($request_token['oauth_token']) && isset($request_token['oauth_token_secret'])) {
$_SESSION['request_token'] = $request_token['oauth_token'];
$_SESSION['request_token_secret'] = $request_token['oauth_token_secret'];
if ($connection->http_code == 200) {
$url = $connection->getAuthorizeURL($request_token['oauth_token']);
header('Location: ' . $url);
}
} else {