/** * @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; }
/** * * @param array|object $access_token */ public function initialize($access_token) { self::$object = new SJB_LinkedIn(); if (self::$object->_getAccessToken($access_token)) { return $this->getProfileInformation(); } return null; }
/** * @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; }