/**
  * @param int $listingSID
  * @return bool
  */
 public function postListing($listingSID)
 {
     $linkedIn = new SJB_LinkedIn();
     $linkedIn->_getAccessToken(unserialize($this->feedInfo['access_token']));
     $listing = SJB_ListingManager::getObjectBySID($listingSID);
     if (!$listing instanceof SJB_Listing) {
         $params = array($listingSID);
         $message = 'Listing #$param_0 does not exist in system';
         throw new SJB_FeedException($message, $params);
     }
     $listingStructure = SJB_ListingManager::createTemplateStructureForListing($listing);
     $link = SJB_ListingManager::getListingUrlBySID($listingSID);
     $userInfo = SJB_Array::get($listingStructure, 'user');
     $this->tp->assign('post_template', $this->feedInfo['post_template']);
     $this->tp->assign('listing', $listingStructure);
     $this->tp->assign('user', $userInfo);
     $title = $this->tp->fetch($this->template);
     if ($this->feedInfo['post_to_updates']) {
         $post['content'] = self::getContentToPostToUpdates($title, $listingStructure['Title'], $link, $userInfo['Logo']['file_url']);
         $linkedIn->postToUpdates($post);
     }
     if (!empty($this->feedInfo['post_to_groups']) && !empty($this->feedInfo['groups'])) {
         $post['content'] = self::getContentToPostToGroup($title, $listingStructure['Title'], $link, $userInfo['Logo']['file_url']);
         $post['groups'] = explode(',', $this->feedInfo['groups']);
         $linkedIn->postToGroups($post);
     }
     return true;
 }
 public function peopleSearch($aFields = array())
 {
     $aPrepared = array();
     if (self::$object && self::$oProfile && is_array($aPrepared)) {
         foreach ($aFields as $fieldName => $fieldValue) {
             if (!empty($fieldValue)) {
                 if ('facet' == $fieldName) {
                     $aPrepared[$fieldName] = $fieldValue;
                 } else {
                     $aPrepared[$fieldName] = urlencode($fieldValue);
                 }
             }
         }
         $response = self::$object->peopleSearch($aPrepared);
         if ($response) {
             $oPersons = new SimpleXMLElement($response);
             if ((int) $oPersons->{'num-results'} >= 0) {
                 return $oPersons;
             }
         }
     }
     return null;
 }
示例#3
0
 /**
  * @return array|null
  */
 public function getGroups()
 {
     if (!is_object(self::$object)) {
         self::$object = new SJB_LinkedIn();
     }
     if (self::$object->_getAccessToken()) {
         $groups = self::$object->getGroups();
         if ($groups) {
             $groupValues = array();
             foreach ($groups->{'group-membership'} as $groupMembership) {
                 $group = $groupMembership->group;
                 $groupsList[(string) $group->id] = (string) $group->name;
             }
             if (!empty($groupsList)) {
                 asort($groupsList, SORT_STRING);
                 foreach ($groupsList as $groupID => $groupName) {
                     $groupValues[] = array('id' => $groupID, 'caption' => $groupName);
                 }
                 return $groupValues;
             }
         }
     }
     return null;
 }