/**
  * Imports all likes from a facebook account to store it in the mongodb
  *
  * @param int $online_identity
  */
 public static function importInterests($online_identity)
 {
     $token = AuthTokenTable::getByUserAndOnlineIdentity($online_identity->getUserId(), $online_identity->getId());
     if (!$token) {
         $online_identity->deactivate();
         throw new Exception('damn theres no token!', '666');
     }
     // get likes
     $response = UrlUtils::sendGetRequest("https://graph.facebook.com/me/likes?access_token=" . $token->getTokenKey());
     // mongo manager
     $dm = MongoManager::getDM();
     // check likes
     if ($response && ($objects = json_decode($response, true))) {
         if (!isset($objects['data'])) {
             return false;
         }
         // iterate and save in mongodb
         foreach ($objects["data"] as $object) {
             $interest = $dm->getRepository('Documents\\Interest')->upsert($object);
             // check interest
             if ($interest) {
                 $user_interest = $dm->getRepository('Documents\\UserInterest')->upsert($online_identity, $interest);
             }
         }
     }
     return;
 }
示例#2
0
 protected function getAuthToken()
 {
     $lToken = AuthTokenTable::getByUserAndOnlineIdentity($this->onlineIdentity->getUserId(), $this->onlineIdentity->getId());
     if (!$lToken) {
         $this->onlineIdentity->setSocialPublishingEnabled(false);
         $this->onlineIdentity->save();
     }
     return $lToken;
 }
示例#3
0
 /**
  * import twitter contacts
  *
  * @author Matthias Pfefferle
  * @author Karina Mies
  */
 public static function importContacts($pOnlineIdentity)
 {
     $lToken = AuthTokenTable::getByUserAndOnlineIdentity($pOnlineIdentity->getUserId(), $pOnlineIdentity->getId());
     // get api informations
     if (!$lToken) {
         $pOnlineIdentity->deactivate();
         throw new Exception('damn theres no token!', '666');
     }
     $lConsumer = new OAuthConsumer(sfConfig::get("app_xing_oauth_token"), sfConfig::get("app_xing_oauth_secret"));
     $lJson = OAuthClient::get($lConsumer, $lToken->getTokenKey(), $lToken->getTokenSecret(), "https://api.xing.com/v1/users/me/contact_ids.json");
     $lJsonFriendsObject = json_decode($lJson, true);
     sfContext::getInstance()->getLogger()->notice(print_r($lJsonFriendsObject, true));
     self::importFriends($pOnlineIdentity, $lJsonFriendsObject);
 }
 /**
  * import twitter contacts
  *
  * @author Matthias Pfefferle
  * @author Karina Mies
  */
 public static function importContacts($pOnlineIdentity)
 {
     $lToken = AuthTokenTable::getByUserAndOnlineIdentity($pOnlineIdentity->getUserId(), $pOnlineIdentity->getId());
     // get api informations
     if (!$lToken) {
         $pOnlineIdentity->deactivate();
         throw new Exception('damn theres no token!', '666');
     }
     $lConsumer = new OAuthConsumer(sfConfig::get("app_linkedin_oauth_token"), sfConfig::get("app_linkedin_oauth_secret"));
     $lXml = OAuthClient::get($lConsumer, $lToken->getTokenKey(), $lToken->getTokenSecret(), "http://api.linkedin.com/v1/people/~/connections:(id)");
     $lFriendObject = simplexml_load_string($lXml);
     $lXml = OAuthClient::get($lConsumer, $lToken->getTokenKey(), $lToken->getTokenSecret(), "http://api.linkedin.com/v1/people/~:(id,site-standard-profile-request,summary,picture-url,first-name,last-name,date-of-birth,location)");
     $lProfileArray = XmlUtils::XML2Array($lXml);
     @self::importFriends($pOnlineIdentity, $lFriendObject);
     @self::updateIdentity($pOnlineIdentity, $lProfileArray);
 }
示例#5
0
 /**
  * import twitter contacts
  *
  * @author Matthias Pfefferle
  * @author Karina Mies
  */
 public static function importContacts($pOnlineIdentity)
 {
     $lToken = AuthTokenTable::getByUserAndOnlineIdentity($pOnlineIdentity->getUserId(), $pOnlineIdentity->getId());
     // get api informations
     if (!$lToken) {
         $pOnlineIdentity->deactivate();
         throw new Exception('damn theres no token!', '666');
     }
     $lConsumer = new OAuthConsumer(sfConfig::get("app_twitter_oauth_token"), sfConfig::get("app_twitter_oauth_secret"));
     $lJson = OAuthClient::get($lConsumer, $lToken->getTokenKey(), $lToken->getTokenSecret(), "http://api.twitter.com/1.1/followers/ids.json?id=" . $pOnlineIdentity->getOriginalId());
     $lJsonFriendsObject = json_decode($lJson);
     // get api informations
     $lJson = OAuthClient::get($lConsumer, $lToken->getTokenKey(), $lToken->getTokenSecret(), "http://api.twitter.com/1.1/users/show.json?user_id=" . $pOnlineIdentity->getOriginalId());
     $lJsonUserObject = json_decode($lJson);
     self::importFriends($pOnlineIdentity, $lJsonFriendsObject);
     self::updateIdentity($pOnlineIdentity, $lJsonUserObject);
 }