TijsVerkoyen\Twitter\Twitter::statusesUserTimeline PHP Метод

statusesUserTimeline() публичный Метод

User timelines belonging to protected users may only be requested when the authenticated user either "owns" the timeline or is an approved follower of the owner. The timeline returned is the equivalent of the one seen when you view a user's profile on twitter.com. This method can only return up to 3,200 of a user's most recent Tweets. Native retweets of other statuses by the user is included in this total, regardless of whether include_rts is set to false when requesting this resource.
public statusesUserTimeline ( string[optional] $userId = null, string[optional] $screenName = null, string[optional] $sinceId = null, int[optional] $count = null, string[optional] $maxId = null, bool[optional] $trimUser = null, bool[optional] $excludeReplies = null, bool[optional] $contributorDetails = null, bool[optional] $includeRts = null ) : array
$userId string[optional]
$screenName string[optional]
$sinceId string[optional]
$count int[optional]
$maxId string[optional]
$trimUser bool[optional]
$excludeReplies bool[optional]
$contributorDetails bool[optional]
$includeRts bool[optional]
Результат array
    public function statusesUserTimeline($userId = null, $screenName = null, $sinceId = null, $count = null, $maxId = null, $trimUser = null, $excludeReplies = null, $contributorDetails = null, $includeRts = null)
    {
        // validate
        if ($userId == '' && $screenName == '') {
            throw new Exception('Specify an userId or a screenName.');
        }
        // build parameters
        $parameters = null;
        if ($userId != null) {
            $parameters['user_id'] = (string) $userId;
        }
        if ($screenName != null) {
            $parameters['screen_name'] = (string) $screenName;
        }
        if ($sinceId != null) {
            $parameters['since_id'] = (string) $sinceId;
        }
        if ($count != null) {
            $parameters['count'] = (int) $count;
        }
        if ($maxId != null) {
            $parameters['max_id'] = (string) $maxId;
        }
        if ($trimUser !== null) {
            $parameters['trim_user'] = $trimUser ? 'true' : 'false';
        }
        if ($excludeReplies !== null) {
            $parameters['exclude_replies'] = $excludeReplies ? 'true' : 'false';
        }
        if ($contributorDetails !== null) {
            $parameters['contributor_details'] = $contributorDetails ? 'true' : 'false';
        }
        if ($includeRts !== null) {
            $parameters['include_rts'] = $includeRts ? 'true' : 'false';
        }
        // make the call
        return $this->doCall('statuses/user_timeline.json', $parameters);
    }

Usage Example

Пример #1
0
 /**
  * Tests Twitter->statusesUserTimeline()
  */
 public function testStatusesUserTimeline()
 {
     $response = $this->twitter->statusesUserTimeline(null, null, null, 2);
     $this->assertEquals(count($response), 2);
     foreach ($response as $row) {
         $this->isTweet($row);
     }
 }
Twitter