DataSift_Source::get PHP Method

get() public static method

Gets a single DataSift_Source object by ID
public static get ( DataSift_User $user, string $id ) : DataSift_Source
$user DataSift_User The user making the request.
$id string The id of the Source to fetch
return DataSift_Source
    public static function get(DataSift_User $user, $id)
    {
        $params = array('id' => $id);
        return new self($user, $user->post('source/get', $params));
    }

Usage Example

Example #1
0
 public function testGetSource()
 {
     $response = array('response_code' => 200, 'data' => array('id' => '78b3601ef667466d95f19570dcb74699', 'name' => 'My PHP managed source', 'created_at' => 1435869526, 'status' => 'active', 'auth' => array(array('identity_id' => '7b1be3a398e646bbb3c7a5cb9717ba45', 'expires_at' => 1495869526, 'parameters' => array('value' => '363056350669209|09af1ce9c5d8d23147ec4eeb9a33aac2'))), 'resources' => array(array('resource_id' => '30bc448896de44b88604ac223cb7f26f', 'status' => 'valid', 'parameters' => array('url' => 'http://www.facebook.com/theguardian', 'title' => 'The Guardian', 'id' => 10513336322))), 'parameters' => array('comments' => true, 'likes' => true, 'page_likes' => true, 'posts_by_others' => true)), 'rate_limit' => 200, 'rate_limit_remaining' => 150);
     DataSift_MockApiClient::setResponse($response);
     $source = DataSift_Source::get($this->user, '78b3601ef667466d95f19570dcb74699');
     $resources = $source->getResources();
     $auth = $source->getAuth();
     $this->assertEquals($source->getId(), '78b3601ef667466d95f19570dcb74699', 'Source ID did not match');
     $this->assertEquals($source->getName(), 'My PHP managed source', 'Name did not match');
     $this->assertEquals($resources[0]['parameters']['id'], 10513336322, 'Resource ID did not match');
     $this->assertEquals($auth[0]['parameters']['value'], '363056350669209|09af1ce9c5d8d23147ec4eeb9a33aac2', 'Auth token did not match');
 }