private function uploadMedia($path, $type)
 {
     //build Mac
     $timeStamp = time();
     $lstParams = array($this->pageId, $timeStamp, $this->secretKey);
     $mac = ZaloSdkHelper::buildMacForAuthentication($lstParams);
     $request = RequestFactory::getInstance()->create('POST', CommonInfo::$DOMAIN . CommonInfo::$SER_UPLOAD)->setClient(new Client())->addPostFiles(array(CommonInfo::$URL_UPLOAD => $path))->addPostFields(array(CommonInfo::$URL_ACT => $type, CommonInfo::$URL_PAGEID => $this->pageId, CommonInfo::$URL_TIMESTAMP => $timeStamp, CommonInfo::$URL_MAC => $mac));
     $response = $request->send()->json();
     $error = $response["error"];
     if ($error < 0) {
         $zaloSdkExcep = new ZaloSdkException();
         $zaloSdkExcep->setZaloSdkExceptionErrorCode($error);
         if (!empty($response["message"])) {
             $zaloSdkExcep->setZaloSdkExceptionMessage($response["message"]);
         }
         throw $zaloSdkExcep;
     } else {
         if (!empty($response["result"])) {
             return $response["result"];
         } else {
             $zaloSdkExcep = new ZaloSdkException();
             $zaloSdkExcep->setZaloSdkExceptionErrorCode(-1);
             throw zaloSdkExcep;
         }
     }
 }
 public function getMessageStatus($msgId)
 {
     $timeStamp = time();
     $client = ZaloSdkHelper::buildRequestD($this->pageId, CommonInfo::$ACT_STT, CommonInfo::$SER_QUERY, $timeStamp);
     //plus param
     ValidateFunc::checkEmptyString($msgId, "Message can't be empty");
     ZaloSdkHelper::addParamsHttpGet($client, CommonInfo::$URL_MSGID, $msgId);
     //build Mac
     $lstParams = array($this->pageId, $msgId, $timeStamp, $this->secretKey);
     $mac = ZaloSdkHelper::buildMacForAuthentication($lstParams);
     ZaloSdkHelper::addParamsHttpGet($client, CommonInfo::$URL_MAC, $mac);
     return ZaloSdkHelper::sendQueryStatusMsgPage($client);
 }
 public function removeFanPageByPhoneNum($phoneNum)
 {
     $timeStamp = time();
     $client = ZaloSdkHelper::buildRequestD($this->pageId, CommonInfo::$ACT_REMOVE_PHONE, CommonInfo::$SER_FAN, $timeStamp);
     //plus param
     ValidateFunc::checkNotNull($phoneNum, "List phone numbers can't be null");
     ValidateFunc::checkListNotEmpty($phoneNum, "List phone numbers can't be empty");
     $strPhoneNums = $this->convertListToArray($phoneNum);
     ZaloSdkHelper::addParamsHttpGet($client, CommonInfo::$URL_UIDS, $strPhoneNums);
     //build Mac
     $lstParams = array($this->pageId, $strPhoneNums, $timeStamp, $this->secretKey);
     $mac = ZaloSdkHelper::buildMacForAuthentication($lstParams);
     ZaloSdkHelper::addParamsHttpGet($client, CommonInfo::$URL_MAC, $mac);
     return ZaloSdkHelper::sendRemoveFan($client);
 }
 public function pushLinkFeed($message, $link, $linkTitle, $linkDesc, $linkThumb)
 {
     $timeStamp = time();
     $client = ZaloSdkHelper::buildRequestC($this->pageId, $message, CommonInfo::$ACT_LINK, CommonInfo::$SER_SOCIAL, $timeStamp);
     //plus param
     ValidateFunc::checkEmptyString($link, "Link can't be empty");
     ValidateFunc::checkEmptyString($linkDesc, "Link description can't be empty");
     ValidateFunc::checkEmptyString($linkThumb, "Link thumbnail can't be empty");
     ValidateFunc::checkEmptyString($linkTitle, "Link title can't be empty");
     ZaloSdkHelper::addParamsHttpGet($client, CommonInfo::$URL_LINK, $link);
     ZaloSdkHelper::addParamsHttpGet($client, CommonInfo::$URL_LINKTITLE, $linkTitle);
     ZaloSdkHelper::addParamsHttpGet($client, CommonInfo::$URL_LINKDES, $linkDesc);
     ZaloSdkHelper::addParamsHttpGet($client, CommonInfo::$URL_LINKTHUMB, $linkThumb);
     //build Mac
     $lstParams = array($this->pageId, $message, $link, $linkTitle, $linkDesc, $linkThumb, $timeStamp, $this->secretKey);
     $mac = ZaloSdkHelper::buildMacForAuthentication($lstParams);
     ZaloSdkHelper::addParamsHttpGet($client, CommonInfo::$URL_MAC, $mac);
     return ZaloSdkHelper::sendMessage($client);
 }