本文整理汇总了PHP中Codebird\Codebird类的典型用法代码示例。如果您正苦于以下问题:PHP Codebird类的具体用法?PHP Codebird怎么用?PHP Codebird使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Codebird类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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");
}
开发者ID:torann,项目名称:skosh,代码行数:13,代码来源:plugin.php
示例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']);
}
开发者ID:pastoremetal,项目名称:twitter-Simple-UI,代码行数:25,代码来源:twitterRequest.php
示例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();
});
}
开发者ID:latelatelate,项目名称:birdy,代码行数:12,代码来源:BirdyServiceProvider.php
示例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);
}
开发者ID:florisand,项目名称:get-tweets,代码行数:27,代码来源:get-tweets.php
示例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']);
}
}
开发者ID:blrik,项目名称:bHome,代码行数:25,代码来源:TwitterClient.php
示例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;
}
开发者ID:mamiya9738,项目名称:tests,代码行数:31,代码来源:userlist.php
示例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;
}
}
开发者ID:Vivalldi,项目名称:tweetcounter,代码行数:36,代码来源:tweetcounter.php
示例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);
}
}
开发者ID:Jsarnik,项目名称:lightregions,代码行数:25,代码来源:sendTweet.php
示例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);
}
开发者ID:cabenitez,项目名称:tweetlight,代码行数:28,代码来源:tweets.php
示例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);
}
开发者ID:cabenitez,项目名称:tweetlight,代码行数:26,代码来源:tweets.php
示例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;
}
开发者ID:MrMitch,项目名称:Les-Joies-de-Supinfo,代码行数:8,代码来源:TwitterService.php
示例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;
}
开发者ID:QasAshraf,项目名称:cuddly-duck,代码行数:8,代码来源:TwitterService.php
示例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);
}
开发者ID:eacquah,项目名称:lolgh,代码行数:8,代码来源:Twitter.php
示例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);
}
开发者ID:henrymidio,项目名称:tweetlight,代码行数:9,代码来源:Tweets.php
示例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;
}
开发者ID:CREATe-centre,项目名称:status-display,代码行数:13,代码来源:display.php
示例16: __construct
public function __construct()
{
Codebird::setConsumerKey(env('TWITTER_CONSUMER_KEY'), env('TWITTER_CONSUMER_SECRET'));
$this->citcuit = new CitcuitController();
$this->api = Codebird::getInstance();
$this->middleware(function ($request, $next) {
$this->api->setToken(session('auth.oauth_token'), session('auth.oauth_token_secret'));
return $next($request);
});
}
开发者ID:dodyagung,项目名称:CitCuit,代码行数:10,代码来源:APIController.php
示例17: twitter
/**
* [twitter description]
* @param [type] $_params array contain twitte params like status
* @param [type] $_token array with 5 key
* [
* ConsumerKey=>'',
* ConsumerSecret=>'',
* AccessToken=>'',
* AccessTokenSecret=>'',
* status=>''
* ]
* @return [type] return status of twitte
*/
public static function twitter($_params, $_token = null)
{
require addons . 'lib/SocialNetwork/codebird/codebird.php';
if (is_array($_token) && count($_token) === 5) {
// use the input array
} else {
// get token value from database if exist
$qry = new \lib\dbconnection();
$qry = $qry->query('Select `option_key`, `option_value` from options where `option_cat` = "twitter"');
if ($qry->num() < 5) {
return 'token';
}
foreach ($qry->allassoc() as $key => $value) {
$_token[$value['option_key']] = $value['option_value'];
}
// if twitter status is disable return false
if (!isset($_token['status'])) {
return 'disable';
}
if ($_token['status'] !== 'enable') {
return 'disable';
}
}
try {
\Codebird\Codebird::setConsumerKey($_token['ConsumerKey'], $_token['ConsumerSecret']);
$cb = \Codebird\Codebird::getInstance();
$cb->setToken($_token['AccessToken'], $_token['AccessTokenSecret']);
if (is_array($_params)) {
// user passed params as twitter parameter like below lines
// https://github.com/jublonet/codebird-php
// $params =
// [
// 'status' => 'I love London',
// 'lat' => 51.5033,
// 'long' => 0.1197,
// 'media_ids' => $media_ids
// ];
} else {
$_params = array('status' => $_params);
}
$reply = array();
$reply['callback'] = $cb->statuses_update($_params);
$reply['status'] = $reply['callback']->httpstatus;
// return $reply;
} catch (\Exception $e) {
$reply['callback'] = $e->getMessage();
$reply['status'] = 'fail';
// var_dump('Caught exception: ', $e->getMessage(), "\n");
// return $e->getMessage();
} finally {
$reply['date'] = date('Y-m-d H:i:s');
return $reply;
}
}
开发者ID:evazzadeh,项目名称:Saloos,代码行数:67,代码来源:SocialNetwork.php
示例18: __construct
public function __construct()
{
$this->config = Zend_Registry::get('config');
\Codebird\Codebird::setConsumerKey($this->config->twitter->consumerKey, $this->config->twitter->consumerSecret);
$this->cb = \Codebird\Codebird::getInstance();
if (isset($this->config->twitter->bearerToken)) {
$bearerToken = $this->config->twitter->bearerToken;
} else {
$bearerToken = $this->_fetchBearerToken();
}
\Codebird\Codebird::setBearerToken($bearerToken);
}
开发者ID:grrr-amsterdam,项目名称:garp3,代码行数:12,代码来源:Twitter.php
示例19: __construct
function __construct($consumerKey, $consumerValue, $tokenKey, $tokenValue, $botName)
{
$this->consumerKey = $consumerKey;
$this->consumerValue = $consumerValue;
$this->tokenKey = $tokenKey;
$this->tokenValue = $tokenValue;
$this->botName = $botName;
$this->percentageThreshold = "";
echo "In construct ";
\Codebird\Codebird::setConsumerKey($this->consumerKey, $this->consumerValue);
// static, see 'Using multiple Codebird instances'
$this->cb = \Codebird\Codebird::getInstance();
$this->cb->setToken($this->tokenKey, $this->tokenValue);
$results = $this->cb->statuses_mentionsTimeline(array("screen_name" => $this->botName, "count" => 5000));
//print_r($results);
$reply_tweet_id = array();
$reply_tweet_time = array();
foreach ($results as $question) {
echo "<h1>" . $question->user->screen_name . "\\ " . $question->in_reply_to_screen_name . "</h1><br>";
if ($question->user->screen_name != '' && $question->in_reply_to_screen_name != '') {
// echo $question->user->screen_name . ": User Screenname<br/>";
// echo $question->user->id . ": User id<br/>";
// echo $question->text . " : USER tweet <br/>";
// echo $question->id_str . " : TWEET ID";
$reply_tweet_id[] = $question->id_str;
$reply_tweet_username[] = $question->user->screen_name;
$reply_tweet_time[] = $question->created_at;
}
// $output[]=$question->user->screen_name;
}
//Checking for API limits. It happens.
if ($DEBUGME == 1) {
echo $results->rate['limit'] . " limit<br>";
echo $results->rate['remaining'] . " remaining<br>";
echo $results->rate['reset'] . " TIME<br>";
}
print_r($reply_tweet_id);
echo "<br>";
print_r($reply_tweet_username);
echo "<br>";
$this->userToTweet = $reply_tweet_username[0];
$this->replyToTweetID = $reply_tweet_id[0];
}
开发者ID:BreaMew,项目名称:SnepBot,代码行数:43,代码来源:SnepBot.class.php
示例20: user_oauth
function user_oauth()
{
//require_once ('codebird.php');
$cb = \Codebird\Codebird::getInstance();
// Flag forces twitter_process() to use OAuth signing
// $GLOBALS['user']['type'] = 'oauth';
// If there's no OAuth Token, take the user to Twiter's sign in page
if (!isset($_SESSION['oauth_token'])) {
// get the request token
$reply = $cb->oauth_requestToken(array('oauth_callback' => SERVER_NAME . $_SERVER['REQUEST_URI']));
// store the token
$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;
// redirect to auth website
$auth_url = $cb->oauth_authorize();
header('Location: ' . $auth_url);
die;
} elseif (isset($_GET['oauth_verifier']) && isset($_SESSION['oauth_verify'])) {
// verify the token
$cb->setToken($_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
unset($_SESSION['oauth_verify']);
// get the access token
$reply = $cb->oauth_accessToken(array('oauth_verifier' => $_GET['oauth_verifier']));
// store the token (which is different from the request token!)
$_SESSION['oauth_token'] = $reply->oauth_token;
$_SESSION['oauth_token_secret'] = $reply->oauth_token_secret;
$cb->setToken($_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
// Verify and get the username
$user = $cb->account_verifyCredentials();
$GLOBALS['user']['username'] = $user->screen_name;
// Store ACCESS tokens in COOKIE
$GLOBALS['user']['password'] = $_SESSION['oauth_token'] . '|' . $_SESSION['oauth_token_secret'];
_user_save_cookie(1);
// send to same URL, without oauth GET parameters
header('Location: ' . BASE_URL);
die;
}
header('Location: ' . BASE_URL);
}
开发者ID:xinyue,项目名称:dabr,代码行数:41,代码来源:user.php
注:本文中的Codebird\Codebird类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论