Exemplo n.º 1
0
 /**
  * @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;
 }
Exemplo n.º 2
0
 /**
  * @param $listingSid
  * @return string
  */
 public static function getBitlyShortenUrlByListingSid($listingSid)
 {
     $listingInfo = SJB_ListingManager::getListingInfoBySID($listingSid);
     $listingType = strtolower(SJB_ListingTypeManager::getListingTypeIDBySID($listingInfo["listing_type_sid"]));
     $listingLongUrl = SJB_System::getSystemSettings("USER_SITE_URL") . "/display-{$listingType}/{$listingSid}/";
     self::$_shortenUrl = self::getListingBitlyShortedUrlBySid($listingSid);
     if (empty(self::$_shortenUrl)) {
         $oAuthUrl = self::$_bitlyOauthApi . "shorten?access_token=" . self::getBitlyTokenId() . "&longUrl=" . urlencode($listingLongUrl);
         $output = json_decode(self::bitlyCurl($oAuthUrl));
         if (isset($output->{"data"}->{"hash"})) {
             self::$_shortenUrl = $output->{"data"}->{"url"};
             self::saveBitlyShortenUrlByListingSid($listingSid);
         } else {
             return $listingLongUrl;
         }
     }
     return self::$_shortenUrl;
 }
Exemplo n.º 3
0
 public function getMessageByListingSIDToPost($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);
     $link = SJB_BitlyManager::getBitlyShortenUrlByListingSid($listingSID);
     $link = " {$link} {$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);
     $post = $text . $link;
     if (mb_strlen($post) > 138) {
         $countStrCut = 138 - mb_strlen($post) - 3;
         $text = mb_substr($text, 0, $countStrCut) . '...';
         $post = $text . $link;
     }
     return $post;
 }