Created
July 16, 2015 03:25
-
-
Save howyi/0681b96bc899a7d2dcbb to your computer and use it in GitHub Desktop.
Tweet with twitterOAuth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
require "twitteroauth/autoload.php"; | |
use Abraham\TwitterOAuth\TwitterOAuth; | |
$tw = "Tweet test"; | |
define('CONSUMER_KEY', 'hoge'); | |
define('CONSUMER_SECRET','foo'); | |
define('OAUTH_CALLBACK', 'http://localhost'); | |
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,$_SESSION['oauth_token'], $_SESSION['oauth_token_secret']); | |
$access_token = $connection->oauth("oauth/access_token", array("oauth_verifier" => $_REQUEST['oauth_verifier'])); | |
$_SESSION['oauth_token'] = $access_token["oauth_token"]; | |
$_SESSION['oauth_token_secret'] = $access_token["oauth_token_secret"]; | |
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,$_SESSION['oauth_token'], $_SESSION['oauth_token_secret']); | |
$connection->post('statuses/update', array('status' => $tw)); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment