当前位置: 首页>>代码示例>>PHP>>正文


PHP Codebird::getInstance方法代码示例

本文整理汇总了PHP中Codebird\Codebird::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Codebird::getInstance方法的具体用法?PHP Codebird::getInstance怎么用?PHP Codebird::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Codebird\Codebird的用法示例。


在下文中一共展示了Codebird::getInstance方法的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");
 }
开发者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: 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

示例6: __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

示例7: 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

示例8: 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

示例9: 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

示例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: __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

示例12: 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

示例13: 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

示例14: 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

示例15: __construct

 /**
  * Initialize service
  */
 public function __construct()
 {
     $this->conf = $this->config('twitter');
     if ($this->configured()) {
         Codebird::setConsumerKey($this->conf['key'], $this->conf['secret']);
         $this->cb = Codebird::getInstance();
         $this->cb->setToken($this->conf['token'], $this->conf['token_secret']);
     }
 }
开发者ID:Max201,项目名称:nanocore,代码行数:12,代码来源:Twitter.php


注:本文中的Codebird\Codebird::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。