/** * @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 $listingSID * @return array|bool */ private static function getButtonDetailsStructureByListingSID($listingSID) { $listingInfo = SJB_ListingManager::getListingInfoBySID($listingSID); if (!empty($listingInfo)) { return array('link' => SJB_ListingManager::getListingUrlBySID($listingSID), 'shorten_url' => SJB_BitlyManager::getBitlyShortenUrlByListingSid($listingSID), 'title' => $listingInfo['Title']); } return false; }
/** * @param $listingSID * @return mixed * @throws Exception */ public function postListing($listingSID) { $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); } $listingInfo = SJB_ListingManager::createTemplateStructureForListing($listing); $listingUrl = SJB_ListingManager::getListingUrlBySID($listingSID); $link = " {$listingUrl} {$this->feedInfo['hash_tags']}"; $userInfo = SJB_Array::get($listingInfo, 'user'); $this->tp->assign('post_template', $this->feedInfo['post_template']); $this->tp->assign('listing', $listingInfo); $this->tp->assign('user', $userInfo); $text = $this->tp->fetch($this->template); $picture = $userInfo['Logo']['file_url'] == null ? SJB_System::getSystemSettings('SITE_URL') . '/' . SJB_TemplatePathManager::getAbsoluteImagePath(SJB_TemplateSupplier::getUserCurrentTheme(), 'main', 'logo.png') : $userInfo['Logo']['file_url']; return $this->postToWall($listingSID, $text . $link, $listingUrl, $picture); }
/** * @param $listingSID */ public static function setMetaOpenGraph($listingSID) { if (!empty($listingSID)) { $listing = SJB_ListingManager::getObjectBySID($listingSID); $listingStructure = SJB_ListingManager::createTemplateStructureForListing($listing); $siteUrl = SJB_System::getSystemSettings("SITE_URL"); $location = SJB_LocationManager::locationFormat(array("location" => $listingStructure['Location'])); $locationFormatted = !empty($location) ? " (" . $location . ")" : ''; $title = htmlspecialchars(strip_tags(trim($listingStructure['Title']))) . $locationFormatted; $logoImage = !empty($listingStructure['user']['Logo']['file_url']) ? $listingStructure['user']['Logo']['file_url'] : ''; $description = self::getListingDescriptionPreparedForSharer($listingStructure); $listingUrl = SJB_ListingManager::getListingUrlBySID($listingSID); $openGraphMetaBlock = "<meta property=\"og:type\" content=\"website\" />\n\t" . "<meta property=\"og:url\" content=\"{$listingUrl}\" />\n\t" . "<meta property=\"og:title\" content=\"{$title}\" />\n\t" . "<meta property=\"og:description\" content=\"{$description}\" />\n\t" . "<meta property=\"og:site_name\" content=\"{$siteUrl}\" />\n\t" . "<meta property=\"og:image\" content=\"{$logoImage}\" />"; $head = SJB_System::getPageHead(); SJB_System::setPageHead($head . ' ' . $openGraphMetaBlock); } }