Skip to content

Instantly share code, notes, and snippets.

@77web
Created July 14, 2011 10:29
Show Gist options
  • Save 77web/1082238 to your computer and use it in GitHub Desktop.
Save 77web/1082238 to your computer and use it in GitHub Desktop.
opAuthWithTwitterPluginでtwitter同時投稿するライブラリの案
<?php
require_once(dirname(__FILE__).'/TwitterOAuth.class.php');
class opAuthWithTwitterPluginTweet
{
protected static $consumer_secret;
protected static $consumer_key;
protected static $oauth_token;
protected static $oauth_secret;
protected static $connection;
const POST_URI = 'https://twitter.com/statuses/update.xml';
public static function setup($member)
{
self::$consumer_key = Doctrine::getTable('SnsConfig')->get('op_auth_TwitterAnywhere_plugin_consumer_key');
self::$consumer_secret = Doctrine::getTable('SnsConfig')->get('op_auth_TwitterAnywhere_plugin_consumer_secret');
self::$oauth_token = $member->getConfig('twitter_oauth_token');
self::$oauth_secret = $member->getConfig('twitter_oauth_token_secret');
self::$connection = new TwitterOAuth(self::$consumer_key, self::$consumer_secret, self::$oauth_token, self::$oauth_secret);
}
public static function tweet($tweet)
{
self::$connection->post(self::POST_URI, array('status'=>$tweet, 'oauth_token'=>self::$oauth_token, 'oauth_secret'=>self::$oauth_secret));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment