コード例 #1
0
 /**
  * Get most recent id's for Twitter & Facebook
  *
  * @return void
  */
 private function initIds()
 {
     $message = new Message();
     if (isTwitterLinked()) {
         $mentionId = $this->twitterContent->newestMentionId();
         $directId = $this->twitterContent->newestDirectId();
         if ($mentionId) {
             $message->tweet_id = $mentionId;
         }
         if ($directId) {
             $message->direct_id = $directId;
         }
     }
     if (isFacebookLinked()) {
         $postId = $this->facebookContent->newestPostId();
         $conversationId = $this->facebookContent->newestConversationId();
         if ($postId) {
             $message->fb_post_id = $postId;
         }
         if ($conversationId) {
             $message->fb_private_id = $conversationId;
         }
     }
     $message->post_date = Carbon::now();
     $message->save();
     $this->log->updateLog('fetching');
 }
コード例 #2
0
 /**
  * Update config file with followers
  * @return void
  */
 public function updateTwitterDashboardStats()
 {
     $followers = $this->twitterContent->fetchFollowers();
     $config = $this->config->first();
     $config->twitter_followers = $followers['followers_count'];
     $config->save();
 }
コード例 #3
0
 /**
  * Gets all direct (private) messages on Twitter
  * @return void
  */
 public function collectDirectMessages()
 {
     $sinceId = latestDirect();
     $directs = $this->twitterContent->fetchDirectMessages($sinceId);
     foreach ($directs as $key => $direct) {
         $date = changeDateFormat($direct['created_at']);
         $message = new Message();
         if ($this->contact->where('twitter_id', $direct['sender']['id_str'])->exists()) {
             $contact = $this->contact->where('twitter_id', $direct['sender']['id_str'])->first();
             if (count($contact->cases)) {
                 $case = $contact->cases()->where('origin', 'Twitter direct')->orderBy('id', 'DESC')->first();
             } else {
                 $case = $this->case->createCase('twitter_direct', $direct, $contact);
             }
             $message->case_id = $case->id;
             $this->case->openCase($case);
         } else {
             $contact = $this->contact->createContact('twitter_direct', $direct);
             $case = $this->case->createCase('twitter_direct', $direct, $contact);
             $message->case_id = $case->id;
         }
         $message->contact_id = $contact->id;
         $message->direct_id = $direct['id_str'];
         $message->message = filterUrl($direct['text']);
         $message->post_date = $date;
         $message->save();
         $this->media->handleMedia($message->id, $direct, 'twitter');
         $this->updateCase($case->id, 'twitter', $direct['id_str']);
     }
 }
コード例 #4
0
 /**
  * Publish Tweet and/or Facebook post
  *
  * @param  Request $request
  *
  * @return view
  */
 public function publish(Request $request)
 {
     $this->validate($request, ['content' => 'required', 'social' => 'required']);
     $content = rawurlencode($request->input('content'));
     if (in_array(self::TYPE_TWITTER, $request->input('social'))) {
         $publishment = $this->twitterContent->publishTweet($content);
         $this->insertPublishment(self::TYPE_TWITTER, $publishment, $content);
     }
     if (in_array(self::TYPE_FACEBOOK, $request->input('social'))) {
         $publishment = $this->facebookContent->publishPost($content);
         $this->insertPublishment(self::TYPE_FACEBOOK, $publishment, $content);
     }
     return back();
 }