TijsVerkoyen\Twitter\Twitter::friendshipsShow PHP Method

friendshipsShow() public method

Returns detailed information about the relationship between two arbitrary users.
public friendshipsShow ( string[optional] $sourceId = null, string[optional] $sourceScreenName = null, string[optional] $targetId = null, string[optional] $targetScreenName = null ) : array
$sourceId string[optional]
$sourceScreenName string[optional]
$targetId string[optional]
$targetScreenName string[optional]
return array
    public function friendshipsShow($sourceId = null, $sourceScreenName = null, $targetId = null, $targetScreenName = null)
    {
        // validate
        if ($sourceId == '' && $sourceScreenName == '') {
            throw new Exception('Specify an sourceId or a sourceScreenName.');
        }
        if ($targetId == '' && $targetScreenName == '') {
            throw new Exception('Specify an targetId or a targetScreenName.');
        }
        // build parameters
        if ($sourceId != null) {
            $parameters['source_id'] = (string) $sourceId;
        }
        if ($sourceScreenName != null) {
            $parameters['source_screen_name'] = (string) $sourceScreenName;
        }
        if ($targetId != null) {
            $parameters['target_id'] = (string) $targetId;
        }
        if ($targetScreenName != null) {
            $parameters['target_screen_name'] = (string) $targetScreenName;
        }
        // make the call
        return $this->doCall('friendships/show.json', $parameters);
    }

Usage Example

 /**
  * Tests Twitter->friendshipsShow
  */
 public function testFriendshipsShow()
 {
     $response = $this->twitter->friendshipsShow(null, 'Bert', null, 'Ernie');
     $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']);
 }
Twitter