Skip to content

Instantly share code, notes, and snippets.

@taroyabuki
Last active December 14, 2015 14:29
Show Gist options
  • Save taroyabuki/5100769 to your computer and use it in GitHub Desktop.
Save taroyabuki/5100769 to your computer and use it in GitHub Desktop.
<?php
header('Content-type:text/plain; charset=utf-8');
session_start();
$oauth = new OAuth($_SESSION['consumer_key'], $_SESSION['consumer_secret'], OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
if (substr(PHP_OS, 0, 3) == 'WIN') {
$caPath = 'C:/xampp/perl/vendor/lib/Mozilla/CA/';
$caInfo = "${caPath}cacert.pem";
$oauth->setCAPath($caPath, $caInfo);
}
$access_token = $_SESSION['access_token'];
$oauth->setToken($access_token['oauth_token'], $access_token['oauth_token_secret']);
$message = 'テスト at ' . time();
$parameters = array('status' => $message);
$oauth->fetch('https://api.twitter.com/1.1/statuses/update.json', $parameters, OAUTH_HTTP_METHOD_POST);
print_r(json_decode($oauth->getLastResponse()));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment