Exemple #1
0
 /**
  * Create skill from data of linkedinSkill
  *
  * @param LinkedinSkill $linkedinSkill
  * @param bool|false $mapSkill
  * @return Skill
  */
 public static function createFromLinkedinSkill(LinkedinSkill $linkedinSkill, $mapSkill = false)
 {
     $skill = new Skill();
     $skill->setName($linkedinSkill->getName());
     if ($mapSkill) {
         $linkedinSkill->setSkill($skill);
     }
     return $skill;
 }
 /**
  * Convert array user data to LinkedinUser
  *
  * @param LinkedinUser $user
  * @return LinkedinUser
  */
 private static function getWebProfile(LinkedinUser $user)
 {
     if (!empty($user->getSiteUrl())) {
         $client = new WebClient();
         $crawler = $client->request('GET', static::LINKEDIN_HOMEPAGE);
         $form = $crawler->selectButton('Sign in')->first()->form();
         $client->submit($form, array('session_key' => static::AUTHEN_EMAIL, 'session_password' => static::AUTHEN_PASSWORD));
         $crawler = $client->request('GET', $user->getSiteUrl());
         $nodeSkills = $crawler->filter('#profile-skills .endorse-item-name');
         $nodeCounts = $crawler->filter('#profile-skills .endorse-count');
         $skills = $nodeSkills->each(function ($node) {
             /** @var Crawler $node */
             return $node->text();
         });
         $counts = $nodeCounts->each(function ($node) {
             /** @var Crawler $node */
             return $node->text();
         });
         $user->setCounts($counts);
         foreach ($skills as $skill) {
             $linkedinSkill = new LinkedinSkill();
             $linkedinSkill->setName($skill);
             $user->addLinkedinSkill($linkedinSkill);
         }
     }
     return $user;
 }