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

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

Returns the befriended user in the requested format when successful. Returns a string describing the failure condition when unsuccessful. If you are already friends with the user a HTTP 403 may be returned, though for performance reasons you may get a 200 OK message even if the friendship already exists. Actions taken in this method are asynchronous and changes will be eventually consistent.
public friendshipsCreate ( string[optional] $userId = null, string[optional] $screenName = null, bool[optional] $follow = false ) : array
$userId string[optional]
$screenName string[optional]
$follow bool[optional]
Результат array
    public function friendshipsCreate($userId = null, $screenName = null, $follow = false)
    {
        // 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;
        }
        $parameters['follow'] = $follow ? 'true' : 'false';
        // make the call
        return $this->doCall('friendships/create.json', $parameters, true, 'POST');
    }

Usage Example

Пример #1
0
 /**
  * Tests Twitter->friendshipsDestroy
  */
 public function testFriendshipsDestroy()
 {
     $response = $this->twitter->friendshipsCreate(null, 'tijsverkoyen');
     $response = $this->twitter->friendshipsDestroy(null, 'tijsverkoyen');
     $this->isUser($response);
 }
Twitter