本文整理汇总了PHP中Codebird\Codebird类的典型用法代码示例。如果您正苦于以下问题:PHP Codebird类的具体用法?PHP Codebird怎么用?PHP Codebird使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Codebird类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fire
public function fire($app, array $request)
{
// CodeBird Instance
\Codebird\Codebird::setConsumerKey($this->getConfig('consumer_key'), $this->getConfig('consumer_secret'));
$cb = \Codebird\Codebird::getInstance();
$cb->setToken($this->getConfig('access_token'), $this->getConfig('access_token_secret'));
$cb->setReturnFormat(CODEBIRD_RETURNFORMAT_JSON);
// Set Values
$username = $this->getConfig('username');
$count = $this->getConfig('count');
// Get timeline
return $cb->statuses_userTimeline("screen_name={$username}&count={$count}&exclude_replies=true");
}
示例2: __construct
public function __construct()
{
\Codebird\Codebird::setConsumerKey('API-KEY', 'API-SECRET');
// static, see 'Using multiple Codebird instances'
$this->cb = \Codebird\Codebird::getInstance();
if (!isset($_SESSION['oauth_token'])) {
$reply = $this->cb->oauth_requestToken(array('oauth_callback' => 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']));
$this->cb->setToken($reply->oauth_token, $reply->oauth_token_secret);
$_SESSION['oauth_token'] = $reply->oauth_token;
$_SESSION['oauth_token_secret'] = $reply->oauth_token_secret;
$_SESSION['oauth_verify'] = true;
$auth_url = $this->cb->oauth_authorize();
header('Location: ' . $auth_url);
die;
} elseif (isset($_GET['oauth_verifier']) && isset($_SESSION['oauth_verify'])) {
$this->cb->setToken($_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
unset($_SESSION['oauth_verify']);
$reply = $this->cb->oauth_accessToken(array('oauth_verifier' => $_GET['oauth_verifier']));
$_SESSION['oauth_token'] = $reply->oauth_token;
$_SESSION['oauth_token_secret'] = $reply->oauth_token_secret;
header('Location: ' . 'index.php');
die;
}
$this->cb->setToken($_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
}
示例3: register
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->bind(\Codebird\Codebird::class, function ($app) {
\Codebird\Codebird::setConsumerKey(config('birdy.CONSUMER_KEY'), config('birdy.CONSUMER_SECRET'));
return \Codebird\Codebird::getInstance();
});
}
示例4: get_most_recent
/**
* Gets most recent tweets
* @param String twitter username (ex. kevindeleon)
* @param String number of tweets
* @param String include retweets true, false
* @return JSON encoded tweets
*/
public static function get_most_recent($screen_name, $count, $retweets = NULL)
{
//let's include codebird, as it's going to be doing the oauth lifting for us
require_once 'codebird.php';
//These are your keys/tokens/secrets provided by Twitter
$CONSUMER_KEY = '<YOUR KEY>';
$CONSUMER_SECRET = '<YOUR SECRET>';
$ACCESS_TOKEN = '<YOUR TOKEN>';
$ACCESS_TOKEN_SECRET = '<YOUR TOKEN SECRET>';
//Get authenticated
\Codebird\Codebird::setConsumerKey($CONSUMER_KEY, $CONSUMER_SECRET);
$cb = \Codebird\Codebird::getInstance();
$cb->setToken($ACCESS_TOKEN, $ACCESS_TOKEN_SECRET);
//These are our params passed in
$params = array('screen_name' => $screen_name, 'count' => $count, 'include_rts' => $retweets);
//tweets returned by Twitter
$tweets = (array) $cb->statuses_userTimeline($params);
//Let's encode it for our JS/jQuery
return json_encode($tweets);
}
示例5: __construct
public function __construct($consumer_key = null, $consumer_secret = null, $count_messages = 20, $count_timeline = 40)
{
$this->count_messages = $count_messages;
$this->count_timeline = $count_timeline;
Codebird::setConsumerKey($consumer_key, $consumer_secret);
$this->cb = Codebird::getInstance();
if (isset($_GET['oauth_verifier']) && isset($_SESSION['twitter_verify'])) {
$this->cb->setToken($_SESSION['twitter']['oauth_token'], $_SESSION['twitter']['oauth_token_secret']);
unset($_SESSION['twitter_verify']);
$reply = $this->cb->oauth_accessToken(['oauth_verifier' => $_GET['oauth_verifier']]);
$twitterOauth = TwitterClientOauth::where('user_id', $_SESSION['user_id'])->first();
if ($twitterOauth) {
$twitterOauth->update(['user_id' => $_SESSION['user_id'], 'oauth_token' => $reply->oauth_token, 'oauth_token_secret' => $reply->oauth_token_secret, 'screen_name' => $reply->screen_name, 'oauth_verifier' => true]);
} else {
TwitterClientOauth::create(['user_id' => $_SESSION['user_id'], 'oauth_token' => $reply->oauth_token, 'oauth_token_secret' => $reply->oauth_token_secret, 'screen_name' => $reply->screen_name, 'oauth_verifier' => true]);
}
$_SESSION['twitter']['oauth_token'] = $reply->oauth_token;
$_SESSION['twitter']['oauth_token_secret'] = $reply->oauth_token_secret;
$_SESSION['twitter']['screen_name'] = $reply->screen_name;
$_SESSION['twitter']['twitterOauth'] = true;
}
if (isset($_SESSION['twitter'])) {
$this->cb->setToken($_SESSION['twitter']['oauth_token'], $_SESSION['twitter']['oauth_token_secret']);
}
}
示例6: ViewList
function ViewList()
{
$params = array('screen_name' => $_SESSION['me']['tw_screen_name']);
\Codebird\Codebird::setConsumerKey(CONSUMER_KEY, CONSUMER_SECRET);
$cb = \Codebird\Codebird::getInstance();
$cb->setToken($_SESSION['me']['tw_access_token'], $_SESSION['me']['tw_access_token_secret']);
$userShow = $cb->users_show($params);
$strList = "<ui>";
$strList = $strList . "<div onclick=\"obj=document.getElementById('menu').style; obj.display=(obj.display=='none')?'block':'none';\">";
$strList = $strList . "<a style=\"cursor:pointer;\">";
$strList = $strList . "<img alt=\"" . $userShow->screen_name . "\" src=\"" . $userShow->profile_image_url_https . "\" >";
$strList = $strList . "</a>";
$strList = $strList . "</div>";
$params = array('user_id' => $_SESSION['me']['tw_user_id']);
$user = $cb->friends_ids($params);
$strList = $strList . "<li>";
foreach ($user->ids as $id) {
$params = array('user_id' => $id);
$userFriend = $cb->users_show($params);
$strList = $strList . "<div id=\"user_icon\">";
$strList = $strList . "<form action=\"userview.php\" target=\"_blank\" method=\"POST\">";
$strList = $strList . "<input type=\"image\" alt=\"" . $userFriend->screen_name . "\" src=\"" . $userFriend->profile_image_url_https . "\" ";
$strList = $strList . "name=\"" . $userFriend->screen_name . "\" ";
$strList = $strList . ">";
$strList = $strList . "</form>";
$strList = $strList . "</div>";
}
$strList = $strList . "</li>";
$strList = $strList . "</ul>";
echo $strList;
}
示例7: initialize
/**
* Initialize login plugin if path matches.
*/
public function initialize()
{
/** @var Uri $uri */
$uri = $this->grav['uri'];
// Autoload classes
$autoload = __DIR__ . '/vendor/autoload.php';
if (!is_file($autoload)) {
throw new \Exception('Login Plugin failed to load. Composer dependencies not met.');
}
require_once $autoload;
if ($uri->path() == "/twittercounter") {
//AUTHORIZE TWITTER USING CODEBIRD
\Codebird\Codebird::setConsumerKey("e1tnpPE0Yn21ihdmdiIkCoXwW", "HCjxxLTjaHYxvcO0PwS65Fy5deULMDYyts2Y63fi1IRGHSl8fc");
$this->codebird = \Codebird\Codebird::getInstance();
$authReply = $this->codebird->oauth2_token();
$bearer_token = $authReply->access_token;
$this->codebird->setToken('3857076435-E8PgaMjUlOTOKZrgnILDSnhbFVyyerqRH5B2qyA', 'pwIDLs6FUuoISVFFh59YJcC78PF72ZZYZFaKF8njXdNMW');
//RUN COUNT
$this->currentHashtag = 1;
$first = $this->hashtagCounter();
$this->currentHashtag = 2;
$second = $this->hashtagCounter();
$this->currentHashtag = 3;
$third = $this->hashtagCounter();
$this->currentHashtag = 4;
$fourth = $this->hashtagCounter();
$this->currentHashtag = 5;
$fifth = $this->hashtagCounter();
echo json_encode(array('hashtags' => array($first, $second, $third, $fourth, $fifth)));
//$this->displayStatuses();
exit;
}
}
示例8: Send
function Send($params)
{
echo $_SERVER['DOCUMENT_ROOT'];
require_once $_SERVER['DOCUMENT_ROOT'] . '/codebird/codebird.php';
try {
$consumer_key = "iD1vnMw3VMn1ptYZx4JBWl895";
$consumer_secret = "CIR3jEUXXR5Yxi6K1j6HDdNsKNGXoECfARn8JasK0q09AN5WJm";
$access_token = "3111426681-HJXPz0Fz7Ofjd3GmBXx6tZyK9sGJBPTsmoKpKZW";
$access_secret = "vv23K574Re2x3p5QSZ29ugPyaNS7b3cB2CVTzlh15XHwq";
$cb;
// Fetch new Twitter Instance
$cb = \Codebird\Codebird::getInstance();
$cb->setConsumerKey($consumer_key, $consumer_secret);
//\Codebird\Codebird::setConsumerKey($this->consumer_key, $this->consumer_secret);
//$this->twitter = Codebird::getInstance();
// Set access token
$cb->setToken($access_token, $access_secret);
//$this->twitter->setToken($this->access_token, $this->access_secret);
//$reply = $cb->statuses_update($params);
$reply = $cb->statuses_updateWithMedia($params);
} catch (Exception $ex) {
echo $ex;
file_put_contents('tmp/Log.txt', $ex->getMessage(), FILE_APPEND);
}
}
示例9: user_timeline
public static function user_timeline()
{
// Twitter OAuth library: https://github.com/mynetx/codebird-php
require_once '../codebird.php';
// Twitter OAuth Settings:
$CONSUMER_KEY = '';
$CONSUMER_SECRET = '';
$ACCESS_TOKEN = '';
$ACCESS_TOKEN_SECRET = '';
// Get authenticated:
\Codebird\Codebird::setConsumerKey($CONSUMER_KEY, $CONSUMER_SECRET);
$cb = \Codebird\Codebird::getInstance();
$cb->setToken($ACCESS_TOKEN, $ACCESS_TOKEN_SECRET);
// Retrieve posts:
$username = strip_tags(trim($_GET['username']));
$count = strip_tags(trim($_GET['count']));
// API Settings: https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline
$params = array('screen_name' => $username, 'count' => $count);
// Make the REST call:
$data = (array) $cb->statuses_userTimeline($params);
unset($data['httpstatus']);
unset($data['rate']);
foreach ($data as $tweet) {
$tweets[] = array('username' => $tweet->user->screen_name, 'profile_image' => $tweet->user->profile_image_url, 'text' => $tweet->text, 'created' => $tweet->created_at);
}
// Output result in JSON:
return json_encode($tweets);
}
示例10: hashtag
public static function hashtag()
{
// Twitter OAuth library: https://github.com/mynetx/codebird-php
require_once '../codebird.php';
// Twitter OAuth Settings:
$CONSUMER_KEY = '';
$CONSUMER_SECRET = '';
$ACCESS_TOKEN = '';
$ACCESS_TOKEN_SECRET = '';
// Get authenticated:
\Codebird\Codebird::setConsumerKey($CONSUMER_KEY, $CONSUMER_SECRET);
$cb = \Codebird\Codebird::getInstance();
$cb->setToken($ACCESS_TOKEN, $ACCESS_TOKEN_SECRET);
// Retrieve posts:
$q = strip_tags(trim($_GET['q']));
$count = strip_tags(trim($_GET['count']));
// API Settings: https://dev.twitter.com/docs/api/1.1/get/search/tweets
$params = array('q' => $q, 'count' => $count);
// Make the REST call:
$data = (array) $cb->search_tweets($params);
unset($data['search_metadata']);
unset($data['httpstatus']);
unset($data['rate']);
// Output result in JSON:
return json_encode($data);
}
示例11: postTweet
private function postTweet($text)
{
Codebird::setConsumerKey($this->container->getParameter('twitter_consumer_key'), $this->container->getParameter('twitter_consumer_secret'));
$cb = Codebird::getInstance();
$cb->setToken($this->container->getParameter('twitter_access_token'), $this->container->getParameter('twitter_access_token_secret'));
$reply = $cb->statuses_update('status=' . $text);
return $reply;
}
示例12: postTweet
public function postTweet($status)
{
Codebird::setConsumerKey($this->container->getParameter('hm_twitterApiKey'), $this->container->getParameter('hm_twitterApiSecret'));
$cb = Codebird::getInstance();
$cb->setToken($this->container->getParameter('hm_twitterApiToken'), $this->container->getParameter('hm_twitterApiTokenSecret'));
$reply = $cb->statuses_update('status=' . $status);
return $reply;
}
示例13: __construct
public function __construct()
{
// Fetch new Twitter Instance
Codebird::setConsumerKey($this->consumer_key, $this->consumer_secret);
$this->twitter = Codebird::getInstance();
// Set access token
$this->twitter->setToken($this->access_token, $this->access_secret);
}
示例14: hashtag
public function hashtag()
{
\Codebird\Codebird::setConsumerKey($this->_consumer_key, $this->_consumer_secret);
$cb = \Codebird\Codebird::getInstance();
$cb->setToken($this->_access_token, $this->_access_token_secret);
$params = array('q' => isset($_GET['hashtag']) ? $_GET['hashtag'] : NULL, 'count' => isset($_GET['count']) ? $_GET['count'] : 10);
$data = (array) $cb->search_tweets($params);
return json_encode($data);
}
示例15: get_codebird_instance
/**
* Returns an initialized Codebird instance.
* @return mixed initialized Codebird instance
*/
function get_codebird_instance()
{
require_once 'codebird.php';
global $current_user;
\Codebird\Codebird::setConsumerKey(get_option('status-twitter-oauth-consumer-key'), get_option('status-twitter-oauth-consumer-secret'));
$cb = \Codebird\Codebird::getInstance();
$cb->setToken(get_user_meta($current_user->ID, 'oauth_token', true), get_user_meta($current_user->ID, 'oauth_token_secret', true));
return $cb;
}