public friendshipsUpdate ( string[optional] $userId = null, string[optional] $screenName = null, bool[optional] $device = null, bool[optional] $retweets = null ) : array | ||
$userId | string[optional] | |
$screenName | string[optional] | |
$device | bool[optional] | |
$retweets | bool[optional] | |
return | array |
public function friendshipsUpdate($userId = null, $screenName = null, $device = null, $retweets = 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 ($device !== null) {
$parameters['device'] = (bool) $device ? 'true' : 'false';
}
if ($retweets !== null) {
$parameters['retweets'] = (bool) $retweets ? 'true' : 'false';
}
// make the call
return $this->doCall('friendships/update.json', $parameters, true, 'POST');
}
/** * Tests Twitter->friendshipsUpdate */ public function testFriendshipsUpdate() { $response = $this->twitter->friendshipsUpdate(null, 'sumocoders', true, true); $this->assertArrayHasKey('relationship', $response); $this->assertArrayHasKey('target', $response['relationship']); $this->assertArrayHasKey('followed_by', $response['relationship']['target']); $this->assertArrayHasKey('following', $response['relationship']['target']); $this->assertArrayHasKey('screen_name', $response['relationship']['target']); $this->assertArrayHasKey('id', $response['relationship']['target']); $this->assertArrayHasKey('source', $response['relationship']); $this->assertArrayHasKey('followed_by', $response['relationship']['source']); $this->assertArrayHasKey('following', $response['relationship']['source']); $this->assertArrayHasKey('screen_name', $response['relationship']['source']); $this->assertArrayHasKey('id', $response['relationship']['source']); }