本文整理匯總了PHP中Twitter::instance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twitter::instance方法的具體用法?PHP Twitter::instance怎麽用?PHP Twitter::instance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Twitter
的用法示例。
在下文中一共展示了Twitter::instance方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: update_status
public static function update_status($str)
{
$bitly = new Url_Shortner(array("login" => ORM::factory('setting', 'bitly_login')->value, "key" => ORM::factory('setting', 'bitly_api')->value));
$str = $bitly->string_shorten($str);
$twitter = Twitter::instance(ORM::factory('setting', 'twitter_username')->value, ORM::factory('setting', 'twitter_password')->value);
$twitter->update_status($str);
}
示例2: instance
public static function instance()
{
if (null === self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
示例3: __twitter
public function __twitter()
{
$twitter_username = ORM::factory('setting', 'twitter_username');
$twitter_password = ORM::factory('setting', 'twitter_password');
if (isset($_POST['twitter'])) {
$twitter_username->value = $_POST['twitter_username'];
$twitter_username->save();
$twitter_password->value = $_POST['twitter_password'];
$twitter_password->save();
}
if (isset($_POST['tweet']) && $_POST['tweet'] != '') {
$twitter = Twitter::instance(ORM::factory('setting', 'twitter_username')->value, ORM::factory('setting', 'twitter_password')->value);
$twitter->update_status($_POST['tweet']);
$this->__throw_success('Just tweeted!');
}
$html = form::open(NULL);
$html .= '<p><a href="http://twitter.com/" target="_BLANK">What is twitter?</a></p>';
$html .= form::hidden('twitter', 'true');
$html .= form::label('twitter_username', 'Username');
$html .= form::input('twitter_username', ORM::factory('setting', 'twitter_username')->value, 'class="fullWidth"');
$html .= form::label('twitter_password', 'Password');
$html .= form::password('twitter_password', ORM::factory('setting', 'twitter_password')->value, 'class="fullWidth"');
$html .= form::submit('submit', 'Save', 'class="submit"') . '<p> </p><p> </p>';
$html .= form::close();
$twitter = Twitter::instance(ORM::factory('setting', 'twitter_username')->value, ORM::factory('setting', 'twitter_password')->value);
if (IS_ONLINE && $twitter->account_valid()) {
$html .= form::open(NULL);
$html .= form::label('tweet', 'Post a tweet');
$html .= form::textarea(array('name' => 'tweet', 'class' => 'fullWidth no-editor', 'style' => 'height:50px;'));
$html .= form::submit('submit', 'Tweet', 'class="submit"') . '<p> </p><p> </p>';
$html .= form::close();
$html .= '<h2>Recent Tweets</h2>';
$recent_tweets = json_decode($twitter->user_timeline(null, 5));
foreach ($recent_tweets as $tweet) {
$html .= '<p>' . date('d-m-y', strtotime($tweet->created_at)) . ' ' . text::auto_link($tweet->text) . '</p>';
}
$html .= '<h2>Recent Replies</h2>';
$recent_tweets = json_decode($twitter->replies());
$count = 0;
foreach ($recent_tweets as $tweet) {
if ($count == 5) {
break;
}
$html .= '<p>' . date('d-m-y', strtotime($tweet->created_at)) . ' ' . text::auto_link($tweet->text) . '</p>';
$count++;
}
}
return $html;
}
示例4: friends_timeline
public function friends_timeline()
{
Twitter::instance()->format('json')->friends_timeline(NULL, NULL, 1);
}