Skip to content

Instantly share code, notes, and snippets.

@ko31
Last active August 29, 2015 14:24
Show Gist options
  • Save ko31/f0ba9e0b9c8aeb5dce97 to your computer and use it in GitHub Desktop.
Save ko31/f0ba9e0b9c8aeb5dce97 to your computer and use it in GitHub Desktop.
【PHP】TwitterOAuthからツイート投稿
<?php
// TwitterOAuthライブラリ読み込み
require "twitteroauth/autoload.php";
use Abraham\TwitterOAuth\TwitterOAuth;
// TwitterのAPIキー情報
$consumerKey = "【コンシューマキー】";
$consumerSecret = "【コンシューマシークレット】";
$accessToken = "【アクセストークン】";
$accessTokenSecret = "【アクセストークンシークレット】";
// OAuth認証してAPI接続
$connection = new TwitterOAuth($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);
// ツイート投稿
$message = "テストツイートです";
$response = $connection->post("statuses/update", array("status" => $message));
var_dump($response);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment