本文整理匯總了PHP中Twitter::get方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twitter::get方法的具體用法?PHP Twitter::get怎麽用?PHP Twitter::get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Twitter
的用法示例。
在下文中一共展示了Twitter::get方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: loadUserByUsername
public function loadUserByUsername($username)
{
$user = $this->findUserByTwitterId($username);
if (!empty($user)) {
return $user;
}
$this->twitter_oauth->setOAuthToken($this->session->get('access_token'), $this->session->get('access_token_secret'));
try {
$info = $this->twitter_oauth->get('account/verify_credentials');
} catch (Exception $e) {
$info = null;
}
if (!empty($info)) {
if (empty($user)) {
$user = $this->userManager->createUser();
$user->setEnabled(true);
$user->setPassword('');
}
$user->setTwitterData($info);
$this->userManager->updateUser($user);
}
if (empty($user)) {
throw new UsernameNotFoundException('The user is not authenticated on twitter');
}
return $user;
}
示例2: login_with_oauth
/**
* Figure out identity of the Twitterrer and log them in
*/
protected function login_with_oauth($token, $secret)
{
$twitter = new Twitter();
$twitter->setToken($token, $secret);
$creds = $twitter->get('/account/verify_credentials.json');
$user = $twitter->user_from_response($creds);
$user->twitter_oauth_token = $token;
$user->twitter_oauth_token_secret = $secret;
$user->save();
$this->login_user($user);
// return $this->return_to(); // since return_to saves any stupid URL, this causes redirect loops
return array('redirect' => '/');
}
示例3: loadUserByUsername
public function loadUserByUsername($username)
{
$user = $this->findUserByTwitterUsername($username);
$this->twitterOauth->setOAuthToken($this->session->get('access_token'), $this->session->get('access_token_secret'));
try {
$info = $this->twitterOauth->get('account/verify_credentials');
} catch (\Exception $e) {
$info = null;
}
if (!empty($info)) {
if (isset($info->errors) && is_array($info->errors) && count($info->errors)) {
throw new AuthenticationException($info->errors[0]->message, $info->errors[0]->code);
}
if (empty($user)) {
$user = $this->userManager->createUser();
$user->setEnabled(true);
$user->setLocked(false);
}
$username = $info->screen_name;
$user->setTwitterID($info->id);
$user->setTwitterUsername($username);
$email = $user->getEmail();
if (is_null($email) || strlen(trim($email)) === 0) {
$user->setEmail($username . '@twitter.com');
}
if (null === $user->getUsername()) {
$user->setUsername($username);
}
$user->setFullName($info->name);
$this->userManager->updateUser($user);
}
if (empty($user)) {
throw new UsernameNotFoundException('The user is not authenticated on twitter');
}
return $user;
}
示例4: widget
function widget($args, $instance)
{
extract($args, EXTR_SKIP);
echo $before_widget;
$twitter_username = empty($instance['twitter_username']) ? ' ' : apply_filters('widget_title', $instance['twitter_username']);
$title = $instance['title'];
$items = empty($instance['items']) ? ' ' : apply_filters('widget_title', $instance['items']);
if (!is_numeric($items)) {
$items = 5;
}
if (empty($title)) {
$title = 'Recent Tweets';
}
if (!empty($items) && !empty($twitter_username)) {
// Begin get user timeline
include_once TEMPLATEPATH . "/lib/twitter.lib.php";
$obj_twitter = new Twitter($twitter_username);
$tweets = $obj_twitter->get($items);
if (!empty($tweets)) {
echo '<h2 class="widgettitle">' . $title . '</h2>';
echo '<ul class="twitter">';
foreach ($tweets as $tweet) {
echo '<li>';
if (isset($tweet[0])) {
echo $tweet[0];
}
echo '</li>';
}
echo '</ul>';
echo '<div class="twitter_arrow"></div>';
echo '<div class="twitter_username"><img src="' . get_stylesheet_directory_uri() . '/images/icon_twitter_bird.png" class="middle" alt="" style="margin-right:5px"/>Follow <a href="http://twitter.com/' . $twitter_username . '">@' . $twitter_username . '</a></div>';
}
}
echo $after_widget;
}
示例5: twitter_func
function twitter_func($atts, $content)
{
//extract short code attr
extract(shortcode_atts(array('items' => 5, 'username' => ''), $atts));
$return_html = '';
if (!empty($username)) {
get_template_part(TEMPLATEPATH . "/lib/twitter.lib.php");
$obj_twitter = new Twitter($username);
$tweets = $obj_twitter->get($items);
$return_html = '<ul class="twitter">';
foreach ($tweets as $tweet) {
$return_html = '<li>';
if (isset($tweet[0])) {
$return_html = '<a href="' . $tweet[2][0] . '">' . $tweet[0] . '</a>';
}
$return_html = '</li>';
}
$return_html = '</ul>';
}
return $return_html;
}
示例6: widget
function widget($args, $instance)
{
extract($args, EXTR_SKIP);
echo $before_widget;
$twitter_username = empty($instance['twitter_username']) ? ' ' : apply_filters('widget_title', $instance['twitter_username']);
$title = $instance['title'];
$items = empty($instance['items']) ? ' ' : apply_filters('widget_title', $instance['items']);
$items = absint($items);
$consumer_key = get_option(SHORTNAME . "_twitter_consumer_key");
$consumer_secret = get_option(SHORTNAME . "_twitter_consumer_secret");
$access_token = get_option(SHORTNAME . "_twitter_consumer_token");
$access_token_secret = get_option(SHORTNAME . "_twitter_consumer_token_secret");
if (!is_numeric($items)) {
$items = 5;
}
if (empty($title)) {
$title = 'Recent Tweets';
}
if (!empty($items) && !empty($twitter_username)) {
// Begin get user timeline
include_once get_template_directory() . "/lib/twitter.lib.php";
$obj_twitter = new Twitter($twitter_username);
$obj_twitter->consumer_key = $consumer_key;
$obj_twitter->consumer_secret = $consumer_secret;
$obj_twitter->access_token = $access_token;
$obj_twitter->access_token_secret = $access_token_secret;
$tweets = $obj_twitter->get($items);
if (!empty($tweets)) {
echo '<h2 class="widgettitle">' . $title . '</h2>';
echo '<ul class="twitter">';
foreach ($tweets as $tweet) {
echo '<li>';
if (isset($tweet['text'])) {
echo $tweet['text'];
}
echo '</li>';
}
echo '</ul>';
}
}
echo $after_widget;
}
示例7: die
if (!_iscurlinstalled()) {
die('cURL is NOT installed');
}
$username = 'themefuse';
$limit = '5';
if (isset($_REQUEST['username'])) {
$username = $_REQUEST['username'];
}
if (isset($_REQUEST['items'])) {
$limit = $_REQUEST['items'];
}
$limit = intval($limit);
if ($limit == 0) {
$limit = 5;
}
$tweets_content = '';
if (!empty($username)) {
require_once 'TWITTER.php';
$obj_twitter = new Twitter($username);
$tweets = $obj_twitter->get($limit);
$k = 0;
foreach ($tweets as $tweet) {
$tweets_content .= '<li>';
if (isset($tweet[0])) {
$tweets_content .= $tweets[$k][2];
$k++;
}
$tweets_content .= '</li>';
}
}
echo $tweets_content;
示例8: while
// load dependencies
foreach ($config['libraries'] as $library) {
require EXTS_PATH . $library;
}
if ($extensionDir = opendir(EXTS_PATH)) {
while (false !== ($entry = readdir($extensionDir))) {
if (preg_match('/\\.php$/i', $entry) == 1) {
// include these extenssions
require EXTS_PATH . $entry;
}
}
closedir($extensionDir);
}
// load twitter plugin
$twitter = new Twitter();
$tweets = $twitter->get(3);
// load view
switch (preg_replace('/^(\\/.+?)\\?.+$/i', '$1', $_SERVER['REQUEST_URI'])) {
case '/cv':
$detect = new Mobile_Detect();
include 'pages/cv.php';
break;
case '/cv/pdf':
// $mpdf = new mPDF('utf-8', array(244,328));
$mpdf = new mPDF('c', array(244, 315), '', '', 0, 0, 12, 25, 0, 0);
$mpdf->SetDisplayMode('fullpage');
$mpdf->list_indent_first_level = 0;
// 1 or 0 - whether to indent the first level of a list
$contents = file_get_contents('http://' . $_SERVER['SERVER_NAME'] . '/cv');
$mpdf->WriteHTML($contents);
/**
示例9: widget
function widget($args, $instance)
{
extract($args, EXTR_SKIP);
echo $before_widget;
$twitter_username = empty($instance['twitter_username']) ? ' ' : apply_filters('widget_title', $instance['twitter_username']);
$title = $instance['title'];
$items = empty($instance['items']) ? ' ' : apply_filters('widget_title', $instance['items']);
if (!is_numeric($items)) {
$items = 5;
}
if (empty($title)) {
$title = 'Recent Tweets';
}
if (!empty($items) && !empty($twitter_username)) {
// Begin get user timeline
include_once TEMPLATEPATH . "/lib/twitter.lib.php";
$obj_twitter = new Twitter($twitter_username);
$tweets = $obj_twitter->get($items);
if (!empty($tweets)) {
echo '<h2 class="widgettitle">' . $title . '</h2><br/>';
echo '<ul class="twitter">';
foreach ($tweets as $tweet) {
echo '<li>';
if (isset($tweet[0])) {
echo '<a href="' . $tweet[2][0] . '">' . $tweet[0] . '</a>';
}
echo '</li>';
}
echo '</ul>';
}
}
echo $after_widget;
}
示例10: update_twitter_user
/**
* twitterの情報を元にユーザー情報を更新
*
* @param int 更新対象ユーザID
* @return bool 更新
*/
public function update_twitter_user($user_id = null)
{
if (empty($user_id)) {
return false;
}
$twitter_user = \Twitter::get('account/verify_credentials');
// 未登録のtwitter userの場合は登録させない
$user = $this->get_user_by_twitter_id($twitter_user->id);
if ($user and $user_id !== (int) $user['id']) {
return false;
}
$values = array('twitter_id' => $twitter_user->id, 'twitter_name' => $twitter_user->screen_name, 'username' => $twitter_user->name, 'description' => $twitter_user->description, 'image' => $twitter_user->profile_image_url);
return $this->update_user($values, $user_id);
}