Abraham\TwitterOAuth\TwitterOAuth::get PHP Method

get() public method

Make GET requests to the API.
public get ( string $path, array $parameters = [] ) : array | object
$path string
$parameters array
return array | object
    public function get($path, array $parameters = [])
    {
        return $this->http('GET', self::API_HOST, $path, $parameters);
    }

Usage Example

コード例 #1
0
 public function create()
 {
     DB::transaction(function () {
         $twitterClient = new TwitterOAuth(Config::get('services.twitter.consumerKey'), Config::get('services.twitter.consumerSecret'), Config::get('services.twitter.accessToken'), Config::get('services.twitter.accessSecret'));
         // Fetch the tweet information from Twitter, if a tweet id was passed through (it is possible the tweet was created manually without an id)
         if (array_key_exists('tweet_id', $this->input)) {
             $tweet = $twitterClient->get('statuses/show', ['id' => $this->input['tweet_id']]);
             $tweetOwner = $tweet->user;
             $this->object = Object::create(['user_id' => Auth::id(), 'type' => MissionControlType::Tweet, 'tweet_text' => $tweet->text, 'tweet_id' => $tweet->id, 'tweet_parent_id' => $tweet->in_reply_to_status_id, 'size' => strlen($tweet->text), 'title' => $tweet->text, 'summary' => $this->input['summary'], 'cryptographic_hash' => hash('sha256', $tweet->text), 'originated_at' => Carbon::createFromFormat('D M d H:i:s P Y', $tweet->created_at)->toDateTimeString(), 'status' => ObjectPublicationStatus::QueuedStatus]);
         } else {
             $this->object = Object::create(['user_id' => Auth::id(), 'type' => MissionControlType::Tweet, 'tweet_text' => $this->input['tweet_text'], 'size' => strlen($this->input['tweet_text']), 'title' => $this->input['tweet_text'], 'summary' => $this->input['summary'], 'cryptographic_hash' => hash('sha256', $this->input['tweet_text']), 'originated_at' => $this->input['originated_at'], 'status' => ObjectPublicationStatus::QueuedStatus]);
         }
         try {
             if (!isset($tweetOwner)) {
                 $tweetOwner = $twitterClient->get('users/show', ['screen_name' => $this->input['tweet_screen_name']]);
             }
             $tweeter = Tweeter::byScreenName($tweetOwner->screen_name)->firstOrFail();
         } catch (ModelNotFoundException $e) {
             $tweeter = Tweeter::create(['screen_name' => $tweetOwner->screen_name, 'user_name' => $tweetOwner->name, 'description' => $tweetOwner->description]);
             $tweeter->saveProfilePicture();
         }
         $this->object->tweeter()->associate($tweeter);
         $this->createMissionRelation();
         $this->createTagRelations();
         $this->object->push();
     });
     return $this->object;
 }
All Usage Examples Of Abraham\TwitterOAuth\TwitterOAuth::get