Inheritance: extends Illuminate\Support\Facades\Facade
 public function handle()
 {
     $request_token = ['token' => $this->userTwitterToken->short_lived_token, 'secret' => $this->userTwitterToken->long_lived_token];
     // $twitter = App::make('Thujohn\Twitter\Twitter');
     $twitter = Twitter::reconfig($request_token);
     $twitterSincePaginatorData = new GetTwitterSinceIdForPagination($this->userTwitterToken->user_id);
     $twitterSinceId = $twitterSincePaginatorData->retrieve();
     $firstCall = $twitterSinceId === 0 ? true : false;
     do {
         $twitterSincePaginatorData = new GetTwitterSinceIdForPagination($this->userTwitterToken->user_id);
         $twitterSinceId = $twitterSincePaginatorData->retrieve();
         $twitterCallParams = array('id' => $this->userTwitterToken->entity_id, 'count' => 100, 'format' => 'json');
         if ($twitterSinceId > 0) {
             $twitterCallParams['since_id'] = $twitterSinceId;
         }
         $checkIfSocialMediaTokenHasFilters = new CheckIfSocialMediaTokenHasFilters($this->userTwitterToken);
         $filter = $checkIfSocialMediaTokenHasFilters->get();
         $tweets = json_decode(Twitter::getUserTimeline($twitterCallParams));
         foreach ($tweets as $tweet) {
             $assignToDB = false;
             if ($filter) {
                 $checkIfTweetHasFilter = new CheckIfTweetHasFilter($tweet->entities->hashtags, $filter->filter);
                 if ($checkIfTweetHasFilter->check()) {
                     $assignToDB = true;
                 }
             } else {
                 $assignToDB = true;
             }
             if ($assignToDB) {
                 $assignTweetsToDb = new AssignTweetsToDatabase($this->userTwitterToken->user_id, $tweet);
                 $assignTweetsToDb->assign();
             }
         }
         $twitterPaginatorData = new GetTwitterMaxIdForPagination($tweets);
         $twitterMaxId = $twitterPaginatorData->extract();
     } while (!$firstCall && count($tweets) > 0);
 }
 /**
  * Search tweets by place.
  *
  * @param varchar   city
  * @param number    lat
  * @param number    lng
  * @return json
  */
 public function getTweets($city, $lat, $lng)
 {
     $city = strtoupper($city);
     $data = [];
     $tweets = SearchHistory::where('cookie_id', '=', $_COOKIE['id'])->where('search_term', '=', $city)->get();
     if (count($tweets) == 0) {
         $search_status = Twitter::getSearch(['q' => $city, 'geocode' => $lat . "," . $lng . ",50km", 'format' => 'array']);
         foreach ($search_status['statuses'] as $status) {
             $arr = [];
             $arr['cookie_id'] = $_COOKIE['id'];
             $arr['id'] = $status['id'];
             $arr['text'] = $status['text'];
             $arr['tweeted_at'] = $status['created_at'];
             $arr['user']['id'] = $status['user']['id'];
             $arr['user']['name'] = $status['user']['name'];
             $arr['user']['screen_name'] = $status['user']['screen_name'];
             $arr['user']['image'] = $status['user']['profile_image_url_https'];
             $arr['coordinates']['lat'] = $status['coordinates']['coordinates'][0];
             $arr['coordinates']['lng'] = $status['coordinates']['coordinates'][1];
             if ($arr['coordinates']['lng'] != null && $arr['coordinates']['lng'] != null) {
                 array_push($data, $arr);
             }
         }
         SearchHistory::create(['cookie_id' => $_COOKIE['id'], 'search_term' => $city, 'lat' => $lat, 'lng' => $lng, 'tweets' => $data]);
     } else {
         $data = $tweets[0]->tweets;
     }
     return json_encode($data);
 }
 /**
  * Tweet.
  *
  * @param Request $request
  *
  * @return string
  */
 public function tweet(Request $request)
 {
     $tweet_id = array_get($request->all(), 'tweet_id');
     if (empty($tweet_id)) {
         return;
     }
     $tweet = Twitter::getTweet($tweet_id);
     if ($tweet !== false && !empty($tweet)) {
         $return = ['id_str' => $tweet_id, 'text' => $tweet->text, 'created_at' => $tweet->created_at, 'user' => ['name' => $tweet->user->name, 'screen_name' => $tweet->user->screen_name, 'profile_image_url' => $tweet->user->profile_image_url, 'profile_image_url_https' => $tweet->user->profile_image_url_https]];
         echo json_encode($return);
     }
 }
Example #4
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $infos = \Thujohn\Twitter\Facades\Twitter::getUsersLookup(['screen_name' => 'Symfomany', 'format' => 'php']);
     $manager = new \MongoDB\Driver\Manager('mongodb://localhost:27017');
     $collection = new \MongoDB\Collection($manager, 'laravel.tweets');
     if (!empty($infos)) {
         $collection->deleteMany(['origin' => 'Twitter', 'type' => 'infos']);
         $stat = ['origin' => 'Twitter', 'type' => 'infos', 'data' => $infos, 'created' => new \MongoDB\BSON\UTCDatetime(time())];
         $collection->insertOne($stat);
     }
     $tweets = \Thujohn\Twitter\Facades\Twitter::getDmsOut(['format' => 'php']);
     if (!empty($tweets)) {
         $collection->deleteMany(['origin' => 'Twitter', 'type' => 'dmsout']);
         foreach ($tweets as $tweet) {
             $stat = ['origin' => 'Twitter', 'type' => 'dmsout', 'data' => $tweet, 'created' => new \MongoDB\BSON\UTCDatetime(time())];
             $collection->insertOne($stat);
         }
     }
     $tweets = \Thujohn\Twitter\Facades\Twitter::getFavorites(['format' => 'php']);
     if (!empty($tweets)) {
         $collection->deleteMany(['origin' => 'Twitter', 'type' => 'favorites']);
         foreach ($tweets as $tweet) {
             $stat = ['origin' => 'Twitter', 'type' => 'favorites', 'data' => $tweet, 'created' => new \MongoDB\BSON\UTCDatetime(time())];
             $collection->insertOne($stat);
         }
     }
     $tweets = \Thujohn\Twitter\Facades\Twitter::getMentionsTimeline(['count' => 15, 'format' => 'php']);
     if (!empty($tweets)) {
         $collection->deleteMany(['origin' => 'Twitter', 'type' => 'mentionstimeline']);
         foreach ($tweets as $tweet) {
             $stat = ['origin' => 'Twitter', 'type' => 'mentionstimeline', 'data' => $tweet, 'created' => new \MongoDB\BSON\UTCDatetime(time())];
             $collection->insertOne($stat);
         }
     }
     $tweets = \Thujohn\Twitter\Facades\Twitter::getHomeTimeline(['count' => 15, 'format' => 'php']);
     if (!empty($tweets)) {
         $collection->deleteMany(['origin' => 'Twitter', 'type' => 'hometimeline']);
         foreach ($tweets as $tweet) {
             $stat = ['origin' => 'Twitter', 'type' => 'hometimeline', 'data' => $tweet, 'created' => new \MongoDB\BSON\UTCDatetime(time())];
             $collection->insertOne($stat);
         }
     }
     $tweets = \Thujohn\Twitter\Facades\Twitter::getUserTimeline(['screen_name' => 'allocine', 'count' => 15, 'format' => 'php']);
     if (!empty($tweets)) {
         $collection->deleteMany(['origin' => 'Twitter', 'type' => 'usertimeline']);
         foreach ($tweets as $tweet) {
             $stat = ['origin' => 'Twitter', 'type' => 'usertimeline', 'data' => $tweet, 'created' => new \MongoDB\BSON\UTCDatetime(time())];
             $collection->insertOne($stat);
         }
     }
 }
 public function sendRequest($username)
 {
     $user = $username;
     $cacheTag = 'twitterTimeline';
     //config timeline twitter
     $cacheKey = $user . "-" . $cacheTag;
     $cacheLimit = 15;
     $tweets = null;
     /* caching */
     if (Cache::has($cacheKey)) {
         $tweets = Cache::get($cacheKey);
     } else {
         $tweets = Twitter::getUserTimeline(['screen_name' => $user, 'count' => 10, 'format' => 'object']);
         Cache::put($cacheKey, $tweets, $cacheLimit);
     }
     return $tweets;
 }
 /**
  * Initialiser
  *
  * @return Response
  */
 public function init()
 {
     //set number of frames per game
     $data['frames'] = 10;
     //get list of past games
     $games = DB::table('games')->get();
     $data['games'] = $games;
     //check user is logged in
     try {
         if (!Session::get('usr')) {
             $usr = Twitter::get('account/verify_credentials');
             Session::put('usr', $usr);
         }
         $data['usr'] = Session::get('usr');
     } catch (Exception $e) {
         //not logged in
     }
     return view('main', $data);
 }
Example #7
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $now = Carbon::now();
     $profiles = [];
     foreach (Profile::get() as $profile) {
         $profiles[$profile->handle] = $profile->id;
     }
     $result = Twitter::getListMembers(["list_id" => "221897255", "count" => "5000"]);
     $addNewProfiles = false;
     $newprofiles = [];
     foreach ($result->users as $member) {
         if ($member->verified) {
             $screen_name = strtolower($member->screen_name);
             $image = $member->profile_image_url;
             if (!array_key_exists("@" . $screen_name, $profiles)) {
                 $addNewProfiles = true;
                 echo "adding " . $screen_name . " - ";
                 $newprofiles[] = array('name' => $member->name, 'handle' => $screen_name, 'image' => $image, 'current_price' => 0, 'created_at' => $now, 'updated_at' => $now);
             }
         }
     }
     if ($addNewProfiles) {
         //insert new profiles and reload array
         Profile::insert($newprofiles);
         $profiles = [];
         foreach (Profile::get() as $profile) {
             $profiles[$profile->handle] = $profile->id;
         }
     }
     $followerCounts = [];
     $tweetCounts = [];
     foreach ($result->users as $member) {
         $screen_name = strtolower($member->screen_name);
         if (array_key_exists("@" . $screen_name, $profiles)) {
             $profileId = $profiles["@" . $screen_name];
             $followerCounts[] = array('profile_id' => $profileId, 'count' => $member->followers_count, 'created_at' => $now, 'updated_at' => $now);
             $tweetCounts[] = array('profile_id' => $profileId, 'count' => $member->statuses_count, 'created_at' => $now, 'updated_at' => $now);
         }
     }
     FollowerCount::insert($followerCounts);
     TweetCount::insert($tweetCounts);
 }
 public function post($settings, $org)
 {
     $apiId = $settings['registry_info'][0]['publisher_id'];
     $twitter = "";
     if ($org->twitter != "") {
         $twitter = $org->twitter;
         if (substr($twitter, 0, 1) != '@') {
             $twitter = '@' . $twitter;
         }
         $twitter = ' ' . $twitter;
     }
     $status = $org->name . $twitter . " has published their #IATIData. View the data here: ";
     $status .= 'http://iatiregistry.org/publisher/' . $apiId . ' #AidStream';
     try {
         $twitterResponse = Twitter::postTweet(['status' => $status, 'format' => 'json']);
         $this->logger->info(sprintf('Twitter has been successfully publish for %s with info : %s', $org->name, $twitterResponse));
     } catch (\Exception $e) {
         $this->logger->error($e, ['org_name' => $org->name]);
     }
 }
Example #9
0
 public function callback(Request $request)
 {
     if ($request->session()->has('oauth_request_token')) {
         $request_token = ['token' => $request->session()->get('oauth_request_token'), 'secret' => $request->session()->get('oauth_request_token_secret')];
         Twitter::reconfig($request_token);
         $oauth_verifier = false;
         if ($request->has('oauth_verifier')) {
             $oauth_verifier = $request->input('oauth_verifier');
         }
         $token = Twitter::getAccessToken($oauth_verifier);
         if (!isset($token['oauth_token_secret'])) {
             return route('twitter.login')->with('flash_error', 'We could not log you in on Twitter.');
         }
         $credentials = Twitter::getCredentials();
         if (is_object($credentials) && !isset($credentials->error)) {
             $request->session()->put('access_token', $token);
             $request->session()->put('credentials', $credentials);
             return redirect('login')->with('flash_notice', 'Congrats! You\'ve successfully signed in!');
         }
         return route('twitter.error')->with('flash_error', 'Crab! Something went wrong while signing you up!');
     }
 }
Example #10
0
 /**
  * Execute the job.
  * @return void
  */
 public function handle()
 {
     if (env('APP_ENV') !== 'production') {
         Log::info(sprintf('this env is %s. tweet not publish.', env('APP_ENV')));
         return;
     }
     if (starts_with($this->article->name, 'test')) {
         Log::info('this article is test. tweet not publish.');
         return;
     }
     $body = "{$this->article->name} \n {$this->article->title} \n {$this->article->body}";
     if (self::MAX_LENGTH - 30 < mb_strlen($body)) {
         $body = mb_substr($body, 0, self::MAX_LENGTH - 30) . '…';
     }
     $body .= "\n" . env('SITE_URL');
     Log::info("tweet publish id:{$this->article->id}");
     try {
         Twitter::postTweet(['status' => $body, 'format' => 'json']);
         Log::info("tweet complete. id:{$this->article->id}");
     } catch (\Exception $e) {
         Log::error("tweet error. id:{$this->article->id}, message:{$e->getMessage()}, body_count:" . mb_strlen($body));
     }
 }
Example #11
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $infos = \Thujohn\Twitter\Facades\Twitter::getUsersLookup(['screen_name' => 'Symfomany', 'format' => 'php']);
     if (!empty($infos)) {
         DB::connection('mongodb')->collection('stats')->where(['origin' => 'Twitter', 'type' => 'infos'])->delete();
         $stat = new Stats();
         $stat->origin = "Twitter";
         $stat->type = "infos";
         $stat->data = $infos;
         $stat->save();
     }
     $tweets = \Thujohn\Twitter\Facades\Twitter::getDmsOut(['format' => 'php']);
     if (!empty($tweets)) {
         DB::connection('mongodb')->collection('tweets')->where(['origin' => 'Twitter', 'type' => 'dmsout'])->delete();
         foreach ($tweets as $tweet) {
             $vi = new Tweets();
             $vi->origin = "Twitter";
             $vi->type = "dmsout";
             $vi->data = $tweet;
             $vi->save();
         }
     }
     $tweets = \Thujohn\Twitter\Facades\Twitter::getFavorites(['format' => 'php']);
     if (!empty($tweets)) {
         DB::connection('mongodb')->collection('tweets')->where(['origin' => 'Twitter', 'type' => 'favorites'])->delete();
         foreach ($tweets as $tweet) {
             $vi = new Tweets();
             $vi->origin = "Twitter";
             $vi->type = "favorites";
             $vi->data = $tweet;
             $vi->save();
         }
     }
     $tweets = \Thujohn\Twitter\Facades\Twitter::getMentionsTimeline(['count' => 15, 'format' => 'php']);
     if (!empty($tweets)) {
         DB::connection('mongodb')->collection('tweets')->where(['origin' => 'Twitter', 'type' => 'mentionstimeline'])->delete();
         foreach ($tweets as $tweet) {
             $vi = new Tweets();
             $vi->origin = "Twitter";
             $vi->type = "mentionstimeline";
             $vi->data = $tweet;
             $vi->save();
         }
     }
     $tweets = \Thujohn\Twitter\Facades\Twitter::getHomeTimeline(['count' => 15, 'format' => 'php']);
     if (!empty($tweets)) {
         DB::connection('mongodb')->collection('tweets')->where(['origin' => 'Twitter', 'type' => 'hometimeline'])->delete();
         foreach ($tweets as $tweet) {
             $vi = new Tweets();
             $vi->data = $tweet;
             $vi->origin = "Twitter";
             $vi->type = "hometimeline";
             $vi->save();
         }
     }
     $tweets = \Thujohn\Twitter\Facades\Twitter::getUserTimeline(['screen_name' => 'allocine', 'count' => 15, 'format' => 'php']);
     if (!empty($tweets)) {
         DB::connection('mongodb')->collection('tweets')->where(['origin' => 'Twitter', 'type' => 'usertimeline'])->delete();
         foreach ($tweets as $tweet) {
             $vi = new Tweets();
             $vi->data = $tweet;
             $vi->origin = "Twitter";
             $vi->type = "usertimeline";
             $vi->save();
         }
     }
 }
Example #12
0
 public function setStateAttribute($value)
 {
     if (isset($this->attributes[Production::ATTR_STATE])) {
         //Publicacion en redes sociales
         if ($this->attributes[Production::ATTR_STATE] == Production::STATE_PROGRAMMED && $value == Production::STATE_ACTIVE) {
             //PUBLICA EN LA PAGINA DE FACEBOOK LA NUEVA PRODUCCION AGREGADA
             $page_id = "974813252592135";
             $post_url = 'https://graph.facebook.com/' . $page_id . '/feed';
             $page_access_token = 'CAAMlvU2gRHsBAPt2mZBymHkjZChELemLYpyRjMDp6VqjscjB3VwUbGfQsdyuFfNqpFaXZCnvL6ngWorbg6q2V6FP4rrcIUB5dgisdVSr4STFTzecD2zRoOCYFZCei1D6zxNEm0zHZCXr7DFtbMPTIVSioR1sitpGqcV1aTFgZBadL1CVlmbeMk';
             $data['access_token'] = $page_access_token;
             $data['link'] = url("production/" . $this->attributes[Production::ATTR_SLUG]);
             $data['message'] = "¡Hemos agregado recientemente \"" . $this->attributes[Production::ATTR_TITLE] . "\", desde ya puedes disfrutarla online y gratis!";
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, $post_url);
             curl_setopt($ch, CURLOPT_POST, 1);
             curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             curl_exec($ch);
             curl_close($ch);
             //PUBLIC EN TWITTER
             $url = $this->attributes[Production::ATTR_IMAGE];
             $path = public_path("assets/db/images/" . Util::fileExtractName($url) . "." . Util::fileExtractExtension($url));
             $uploaded_media = Twitter::uploadMedia(['media' => File::get($path)]);
             @Twitter::postTweet(['status' => "Hemos agregado \"" . $this->attributes[Production::ATTR_TITLE] . "\" ¡Disfrutalo desde ya!", 'media_ids' => $uploaded_media->media_id_string]);
         }
     }
     $this->attributes[Production::ATTR_STATE] = $value;
 }
Example #13
0
 /**
  * Handle the event.
  *
  * @param  PostWasTweeted  $event
  * @return void
  */
 public function handle(PostWasTweeted $event)
 {
     if (env('APP_ENV') == 'production') {
         Twitter::postTweet(['status' => "New Post '{$event->post['attributes']['title']}' at http://markrailton.com/blog/{$event->post['attributes']['slug']}", 'format' => 'json']);
     }
 }
Example #14
0
<?php

/*
|--------------------------------------------------------------------------
| Notice
|--------------------------------------------------------------------------
|
| This file is unique in that anything in the all or admin section should
| be changed.  Unlike others, change the question as well so it all
| gets translated.  Just leave 'all' and 'admin' as is.
|
*/
return ['titles' => ['admin' => 'Admin', 'header' => 'FAQ', 'subHeader' => 'You have questions, we have answers.', 'submit' => 'Don\'t see your question?  <a href="https://gitreports.com/issue/HatScrubs/GameAccess" target="_blank">Ask here!</a>'], 'all' => ['What is the home page showing?' => 'The home page is currently showing a timeline for Hat Films.  On the
            left you will see the last 3 days of tweets from ' . \Thujohn\Twitter\Facades\Twitter::linkify('@hat_films') . '
            and on the right is the last and next streams.
            <br /><br />
            The stream box will show one of a few different things.  By default it will show a generic placeholder if the
             site has no details about the stream yet.  If the guys are not going to be on that day, you may see an offline
             notice.  If they will be on and have scheduled something in the site you will see the details of that session.
             Lastly, if there is a poll that is scheduled to end on the same day as a stream, you will see it\'s details.', 'How do I join Hat Films for games?' => 'This is a 2 part process.  First you must be subscribed to them on
            twitch.  If you haven\'t subscribed yet, you can do so by
            <a href="http://www.twitch.tv/hatfilms/subscribe?ref=scrubscribers.com" target="_blank">clicking here</a>.  Once you are a
            subscriber either go to ' . link_to_route('link.index', 'linked accounts') . ' and refresh twitch or simply
            logout and back in.  This will "re-check" your subscriber access and give you access to the site.
            <br /><br />
            Now that the site knows you\'re a subscriber, all you have to do is wait for a game to start.  Trott starts these.
            When he does, you will see the ' . link_to_route('home', 'home page') . '  and ' . link_to_route('stream.index', 'stream page') . '
            come to life alerting you that things will kick off soon.  When they do, if you own the game, can play in the game
            at that time and want to, click ready up.  If you are selected (randomly + a bonus everytime you are not selected) you will
            see the password displayed to you.  If not, you will get a message alerting you to wait for the next attempt.', 'How do I change the timezone?' => 'The timezone for the site, by default, is on GMT.  You can change this once you are
            logged in by clicking your name in the upper right and selecting "Profile".  From there, just select the timezone
Example #15
0
 /**
  * Handle the event.
  *
  * @param  UserRegistered  $event
  * @return void
  */
 public function handle(UserRegistered $event)
 {
     Twitter::postTweet(['status' => 'Welcome, "' . $event->user->username . '"" on Laramap! - https://laramap.com/@' . $event->user->username . ' #laramap #artisan', 'format' => 'json']);
 }
 /**
  * Handle the event.
  *
  * @param  UserBecomeSponsor  $event
  * @return void
  */
 public function handle(UserBecomeSponsor $event)
 {
     Twitter::postTweet(['status' => 'Many thanks to , "' . $event->user->username . '" for sponsoring!! - https://laramap.com/@' . $event->user->username . ' #laramap #sponsor', 'format' => 'json']);
 }
 protected function getTwitterFeed($feedname)
 {
     if (!Cache::has($feedname)) {
         if (strpos($feedname, 'Home')) {
             $timeline = Twitter::getHomeTimeline(array('screen_name' => Config::get('feeds.twitterScreenName'), 'count' => 3, 'format' => 'object'));
         } else {
             $timeline = Twitter::getUserTimeline(array('screen_name' => Config::get('feeds.twitterScreenName'), 'count' => 3, 'format' => 'object'));
         }
         Cache::add($feedname, $timeline, 60);
     }
     return Cache::get($feedname);
 }