Example #1
0
 public function saveFeed($feed, $action = '')
 {
     $networkSocialMedia = new SJB_FacebookSocialMedia();
     $accessToken = $networkSocialMedia->getAccessToken();
     $user = $networkSocialMedia->getAccountInfo($feed->getSID());
     $accountName = !empty($user['account_name']) ? $user['account_name'] : '';
     $feed->addProperty(array('id' => 'access_token', 'type' => 'text', 'value' => $accessToken, 'is_system' => true));
     $feed->addProperty(array('id' => 'account_name', 'type' => 'text', 'value' => $accountName, 'is_system' => true));
     $feed->addProperty(array('id' => 'expiration_date', 'type' => 'date', 'value' => SJB_I18N::getInstance()->getDate(date('Y-m-d', time() + 60 * 24 * 60 * 60)), 'is_system' => true));
     parent::saveFeed($feed);
 }
 /**
  * @param $listingSID
  * @param $message
  * @param $listingUrl
  * @param $pictureUrl
  * @return mixed
  * @throws Exception
  */
 private function postToWall($listingSID, $message, $listingUrl, $pictureUrl)
 {
     $facebook = new SJB_FacebookSocialMedia();
     $facebookObj = $facebook->getObject();
     $accountName = $this->feedInfo['account_name'];
     $args = array('access_token' => $this->feedInfo['access_token'], 'message' => $message, 'link' => $listingUrl, 'picture' => $pictureUrl);
     $response = $facebookObj->api("/{$accountName}/feed", "post", $args);
     if (!empty($response->error)) {
         $params = array($listingSID, $response->error);
         $message = 'Error with listing #$param_0 : $param_1';
         throw new Exception($message, $params);
     }
     return $response;
 }
Example #3
0
 /**
  * Constructor
  */
 public function SJB_FacebookSocialMedia()
 {
     // Create our Application instance.
     self::$object = new Facebook(array('appId' => FB_APP_ID, 'secret' => FB_APP_SECRET));
 }