コード例 #1
0
ファイル: login.php プロジェクト: wikidi/twitter
<?php

/**
 * @author Roman Ozana <*****@*****.**>
 */
use twitter\TwitterApi;
use twitter\TwitterException;
session_start();
require_once '../vendor/autoload.php';
$config = (require 'config.php');
try {
    $connection = new TwitterApi($config->consumerKey, $config->consumerSecret);
    $response = $connection->getRequestToken($config->callback);
    /* Save temporary credentials to session. */
    $_SESSION['oauth_token'] = $token = $response->oauth_token;
    $_SESSION['oauth_token_secret'] = $response->oauth_token_secret;
    $url = $connection->getAuthorizeURL($token);
    header('Location: ' . $url);
} catch (TwitterException $e) {
    echo $e->getMessage();
}