Ejemplo n.º 1
0
 /**
  * @covers \Klout\Model\Identity::setKloutId
  * @covers \Klout\Model\Identity::getKloutId
  */
 public function testGetKloutId()
 {
     $identity = new Identity();
     $this->assertNull($identity->getKloutId());
     $identity->setKloutId($this->kloutId);
     $this->assertEquals($this->kloutId, $identity->getKloutId());
 }
Ejemplo n.º 2
0
 /**
  * Get a Klout User by their network ID
  *
  * @param  String                   $networkName
  * @param  String                   $networkUserId
  * @param  Boolean                  $fullData
  * @throws InvalidArgumentException
  * @return \Klout\Model\User
  */
 public function getUserByNetwork($networkName, $networkUserId, $fullData = true)
 {
     $this->assertValidNetworkName($networkName);
     $this->assertValidUserIdForNetwork($networkName, $networkUserId);
     $idString = '';
     $queryParams = array();
     // The calls to the API based on the Twitter sceenName (username)
     // is different from all the other network based ID lookups
     switch ($networkName) {
         case self::NETWORK_TWITTER:
             $queryParams['screenName'] = $networkUserId;
             break;
         default:
             $idString = $networkUserId;
             break;
     }
     /* @var $request Request */
     $request = $this->client->get('identity.json/' . $networkName . '/' . $idString, null, array('query' => $queryParams));
     try {
         $identityData = $request->send()->json();
         $identity = new Identity();
         $identity->setKloutId($identityData['id']);
         $identity->setNetworkName($networkName);
         $identity->setNetworkUserId($networkUserId);
         $user = $this->getUser($identity->getKloutId(), $fullData);
         $user->addIdentity($identity);
     } catch (HttpRequestException $e) {
         $this->handleHttpRequestException($e);
     }
     return $user;
 }