Beispiel #1
0
 /**
  * @param $userId
  * @param $socialId
  * @param $socialTypeId
  * @param $type
  * @param $desc
  * @param $ref
  * @return socialPostModel
  */
 public static function addItem($userId, $socialId, $socialTypeId, $type, $desc, $ref)
 {
     $socialPost = new socialPostModel();
     $socialPost->user_id = $userId;
     $socialPost->social_id = $socialId;
     $socialPost->social_type_id = $socialTypeId;
     $socialPost->type = $type;
     $socialPost->desc = $desc;
     $socialPost->ref = $ref;
     $socialPost->save();
     return $socialPost;
 }
Beispiel #2
0
 public function postToSocial($socialPostId, $userId, $social, $images, $descPost)
 {
     $util = new Util();
     $socialPostModel = new socialPostModel();
     $socialGalleryPostModel = new socialGalleryPostModel();
     $userBusinessSocial = new userBusinessSocialModel();
     if (!$this->isValidSocial($userId, $social->type, $social->socialId)) {
         throw new \Exception('BAD Social ID');
     }
     $socialAccount = $userBusinessSocial->getItem($userId, $social->type, $social->socialId);
     $facebook = $util->initFacebook();
     $facebook->setDefaultAccessToken($socialAccount->token);
     $arrayFbMedia = [];
     foreach ($images as $image) {
         $imagePost = $facebook->postPhoto($image->url, $image->caption);
         $socialGalleryPostModel->updateItem($image->socialGalleryPostId, ['ref' => $imagePost['id']]);
         array_push($arrayFbMedia, $imagePost);
     }
     $socialPost = $facebook->postFeed($arrayFbMedia, $descPost);
     $socialPostModel->updateItem($socialPostId, ['ref' => $socialPost['id']]);
     return $socialPost;
 }