Exemplo n.º 1
2
 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");
 }
 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']);
 }
Exemplo n.º 3
1
 /**
  * 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();
     });
 }
Exemplo n.º 4
1
 /**
  * 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);
 }
Exemplo n.º 5
0
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;
}
Exemplo n.º 6
0
 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']);
     }
 }
Exemplo n.º 7
0
 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);
 }
Exemplo n.º 8
0
 /**
  * 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;
     }
 }
Exemplo n.º 9
0
 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);
 }
Exemplo n.º 10
0
 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);
 }
Exemplo n.º 11
0
 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;
 }
Exemplo n.º 12
0
 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;
 }
Exemplo n.º 13
0
/**
 * 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;
}
Exemplo n.º 14
0
 /**
  * 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']);
     }
 }
Exemplo n.º 15
0
 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);
 }
Exemplo n.º 16
0
 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);
     });
 }
Exemplo n.º 17
0
 /**
  * [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;
     }
 }
Exemplo n.º 18
0
 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);
 }
Exemplo n.º 19
0
 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];
 }
Exemplo n.º 20
0
 /**
  * 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
     // dev.twitter.com -> create an app -> request oauth token. Then look at the oAuth tab.
     $CONSUMER_KEY = '3soJowYY3RvGLyhg4xpoJA';
     $CONSUMER_SECRET = 'ihH6rRYbNB3UszzhDdTKSVez3HCf67KDG0ufE69Oqw';
     $ACCESS_TOKEN = '337592867-PbwVrwFziRbjQvQEFtFpBDmmZs5xt1C1V2fghn8A';
     $ACCESS_TOKEN_SECRET = 'dNt44s1rmu8jh3bfmiyefsJkIIKHUKRYr33Jfx4YdM';
     //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, 'rts' => $retweets);
     //tweets returned by Twitter
     //$tweets = (array) $cb->statuses_userTimeline($params);
     $tweets = (array) $cb->statuses_homeTimeline($params);
     //Let's encode it for our JS/jQuery
     return json_encode($tweets);
 }
Exemplo n.º 21
0
function user_oauth()
{
    \Codebird\Codebird::setConsumerKey(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET);
    $cb = \Codebird\Codebird::getInstance();
    //	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 . ltrim($_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);
}
Exemplo n.º 22
0
 /**
  * Fetch trends from Twitter based on Global and USA scopes.
  *
  * @return array
  */
 private function twitter()
 {
     if (!($result = \Cache::get('twitter'))) {
         Codebird::setConsumerKey(env('TWITTER_KEY'), env('TWITTER_SECRET'));
         $codeBird = Codebird::getInstance();
         $codeBird->setToken(env('TWITTER_TOKEN'), env('TWITTER_TOKEN_SECRET'));
         $usa = (array) $codeBird->trends_place('id=23424977');
         $world = (array) $codeBird->trends_place('id=1');
         if (@$usa[0] && @$world[0]) {
             \Cache::put('twitter', array_merge(array_map(function ($item) {
                 $item->type = 'usa';
                 return $item;
             }, $usa[0]->trends), array_map(function ($item) {
                 $item->type = 'world';
                 return $item;
             }, $world[0]->trends)), Carbon::now()->addMinutes(10));
             $result = \Cache::get('twitter');
         } else {
             $result = array();
         }
     }
     return $result;
 }
Exemplo n.º 23
0
<?php

// DEPENDENCIES ////////////////////////////////////////////////////////
require 'vendor/autoload.php';
require 'classes/baseapimodel.class.php';
require 'config.php';
////////////////////////////////////////////////////////////////////////
session_start();
// let's do it
// twitter
\Codebird\Codebird::setConsumerKey(TWITTER_API_KEY, TWITTER_API_SECRET);
// static, see 'Using multiple Codebird instances'
$oTwitter = \Codebird\Codebird::getInstance();
Exemplo n.º 24
0
<?php

require_once 'codebird.php';
\Codebird\Codebird::setConsumerKey('[KEY]', '[SECRET]');
$cb = \Codebird\Codebird::getInstance();
$cb->setToken('[TOKEN]', '[TOKENSECRET]');
$message = file_get_contents('php://input');
$reply = $cb->statuses_update('status=' . urlencode($message));
$response = array('success' => true);
echo json_encode($response);
Exemplo n.º 25
0
 /**
  * Creates Codebird instance
  *
  * @return Codebird
  */
 public function connect()
 {
     Codebird::setConsumerKey($this->credentials['consumer_key'], $this->credentials['consumer_secret']);
     return Codebird::getInstance();
 }
Exemplo n.º 26
0
        $handler->setFormatter(new \Monolog\Formatter\LineFormatter(null, 'Y-m-d H:i:s', true));
    }
    return $monolog;
}));
$app->register(new SessionServiceProvider());
$app->register(new ConsoleServiceProvider(), array('console.name' => 'GoRemoteCli', 'console.version' => '1.0.0', 'console.project_directory' => __DIR__ . "/GoRemote"));
$app->register(new Silex\Provider\SwiftmailerServiceProvider());
/**
 * This registers $app['memcache'] which is a Memcached instance
 */
$app->register(new MemcacheExtension(), ['memcache.library' => 'memcached', 'memcache.server' => [['127.0.0.1', 11211]]]);
$app['session.storage.handler'] = $app->share(function ($app) {
    return new MemcachedSessionHandler($app['memcache']);
});
$app['twitter'] = $app->share(function ($app) {
    \Codebird\Codebird::setConsumerKey($app['config.twitter']['key'], $app['config.twitter']['secret']);
    $instance = \Codebird\Codebird::getInstance();
    $instance->setToken($app['config.twitter']['token'], $app['config.twitter']['token_secret']);
    return $instance;
});
$app->register(new UrlGeneratorServiceProvider());
$app->register(new ServiceControllerServiceProvider());
$app->register(new DoctrineServiceProvider());
$app["db.options"] = ["driver" => "pdo_mysql", "host" => getenv('APP_MYSQL_HOSTNAME') ?: 'localhost', "dbname" => getenv('APP_MYSQL_DATABASE') ?: 'goremote', "user" => getenv('APP_MYSQL_USERNAME') ?: 'goremote', "password" => getenv('APP_MYSQL_PASSWORD') ?: 'goremote123'];
$app->register(new LewisB\PheanstalkServiceProvider\PheanstalkServiceProvider(), array('pheanstalk.server' => '127.0.0.1'));
if ($app['debug'] === true || $app['debug'] === 'true') {
    if ($app['config.enableProfiler'] == true) {
        $app->register($p = new WebProfilerServiceProvider(), ['profiler.cache_dir' => '/tmp/cache/profiler/']);
        $app->mount('/_profiler', $p);
    }
} else {
<?php

//http://www.pontikis.net/blog/auto_post_on_twitter_with_php
//api id -KQRNLy8L4t8dQ4Loay0N1cGJV
//api secret-lFi8oSsnR2NsHZUkArGFNx4IMa2unFTTxJm4zRWkC7fd9WlKKr
//owner id-837804571
//access token-837804571-OORMT78jbTrbrgiLk2HYKIWyEblUuZN94PWub1pN
//Access token secret-QMB9fvepUud1p8ykK68Ye3O0WfSzWeGfn9WQJbWhqJu08
// require codebird
require_once 'codebird.php';
//\Codebird\Codebird::setConsumerKey("your_ConsumerKey", "your_ConsumerSecret");
\Codebird\Codebird::setConsumerKey("KQRNLy8L4t8dQ4Loay0N1cGJV", "lFi8oSsnR2NsHZUkArGFNx4IMa2unFTTxJm4zRWkC7fd9WlKKr");
$cb = \Codebird\Codebird::getInstance();
//$cb->setToken("your_AccessToken", "your_AccessTokenSecret");
$cb->setToken("837804571-OORMT78jbTrbrgiLk2HYKIWyEblUuZN94PWub1pN", "QMB9fvepUud1p8ykK68Ye3O0WfSzWeGfn9WQJbWhqJu08");
//$data='Company name:'.$corporateName.'    Start date:'.$startDate.'     End Date:'.$endDate.'     Amount funded:'.$Amount.' @jpmorgan #code4good';
$data = "Hie Nandish";
$params = array('status' => $data);
$reply = $cb->statuses_update($params);
echo 'Done';
Exemplo n.º 28
-1
 function verify_twitter_credentials($twitter)
 {
     require_once OTHERS . "twitter/codebird.php";
     \Codebird\Codebird::setConsumerKey($twitter['consumer_key'], $twitter['consumer_secret']);
     $cb = \Codebird\Codebird::getInstance();
     $cb->setToken($twitter['access_token'], $twitter['access_token_secret']);
     $reply = $cb->oauth2_token();
     if (isset($reply->errors)) {
         return array('result' => false, 'message' => $reply->errors[0]->message);
     } else {
         return array('result' => true, 'message' => "Verifying credentials successful!");
     }
 }
Exemplo n.º 29
-1
 public static function processMessage($msg)
 {
     $params = json_decode($msg->body);
     print_r($params);
     try {
         $news = News::findOne($params->news_id);
         $text = mb_substr($news->title, 0, 140 - strlen(Yii::$app->params['domainName'] . $news->getLink()), 'utf-8');
         $text .= " " . Yii::$app->params['domainName'] . $news->getLink();
         Codebird::setConsumerKey(Yii::$app->params['twitter']['consumer_key'], Yii::$app->params['twitter']['consumer_secret']);
         $cb = Codebird::getInstance();
         $cb->setToken(Yii::$app->params['twitter']['access_token'], Yii::$app->params['twitter']['access_token_secret']);
         $params = array('status' => $text, 'media[]' => $params->src);
         $reply = $cb->statuses_updateWithMedia($params);
     } catch (Exception $e) {
         echo $e->getMessage();
     }
     $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
 }
Exemplo n.º 30
-2
 public function pollAction($id)
 {
     $site = $this->getDoctrine()->getRepository('StuartHashtagBundle:Site')->find($id);
     Codebird::setConsumerKey('WQOK7uxRI60gsCTsHnAMw', 'wPlLms2qIeqUBCcdFo2vAOWCcPMUm3hzmgI43EzMs');
     // static, see 'Using multiple Codebird instances'
     $cb = Codebird::getInstance();
     $reply = $cb->oauth2_token();
     $bearer_token = $reply->access_token;
     $reply = $cb->search_tweets('q=' . $site->getHashtag() . '&include_en&rpp=20&show_user=true&include_entities=true&with_twitter_user_id=true&result_type=recent', true);
     $response = array('name' => $site->getName(), 'hashtag' => $site->getHashtag(), 'reply' => $reply);
     return new JsonResponse($response);
 }