コード例 #1
0
 public function __construct($pageId, $secretKey)
 {
     ValidateFunc::checkNotNull($pageId, "Page id cann't be null");
     ValidateFunc::checkEmptyString($secretKey, "Secret key can't be empty");
     $this->pageId = $pageId;
     $this->secretKey = $secretKey;
 }
コード例 #2
0
 public function __construct($appId, $accessTok, $pageId)
 {
     ValidateFunc::checkNotNull($appId, "App id cann't be null");
     ValidateFunc::checkEmptyString($accessTok, "Access token cann't be empty");
     ValidateFunc::checkNotNull($pageId, "Page id cann't be null");
     $this->appId = $appId;
     $this->pageId = $pageId;
     $this->accessTok = $accessTok;
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 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);
 }
コード例 #5
0
 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);
 }
コード例 #6
0
 public static function checkEmptyString($string, $errorMsg)
 {
     ValidateFunc::check($string != null && trim($string) !== "", $errorMsg);
 }
コード例 #7
0
 public static function buildLinksParam($linksInfo)
 {
     $arr = array();
     for ($i = 0; $i < count($linksInfo); $i++) {
         ValidateFunc::checkEmptyString($linksInfo[$i]["link"], "Link can't be empty!");
         ValidateFunc::checkEmptyString($linksInfo[$i]["linkdes"], "Link description can't be empty!");
         ValidateFunc::checkEmptyString($linksInfo[$i]["linktitle"], "Link title can't be empty!");
         ValidateFunc::checkEmptyString($linksInfo[$i]["linkthumb"], "Link thumbnail can't be empty!");
         $arr[] = $linksInfo[$i];
     }
     return json_encode($arr);
 }
コード例 #8
0
 public function getPageInfoOnbehaft()
 {
     $timeStamp = time();
     ValidateFunc::checkNotNull($this->pageId, "Page id can't be null");
     ValidateFunc::checkNotNull($this->appId, "App id can't be null");
     ValidateFunc::checkEmptyString($this->accessToken, "Access token can't be empty");
     if ($smsMsg == null) {
         $smsMsg = "";
     }
     $client = new Client(CommonInfo::$DOMAIN . CommonInfo::$SER_ONBEHALF);
     $params = array(CommonInfo::$URL_ACT => CommonInfo::$ACT_PROFILE, CommonInfo::$URL_PAGEID => $this->pageId, CommonInfo::$URL_APPID => $this->appId, CommonInfo::$URL_ACCESSTOK => $this->accessToken, CommonInfo::$URL_TIMESTAMP => $timeStamp);
     $client->setDefaultOption('query', $params);
     $profileResult = new ZaloProfileResult();
     $profileResult->setErr(-1);
     $profile = ZaloSdkHelper::sendQueryProfile($client);
     if ($profile != null) {
         $profileResult->setProfile($profile);
         $profileResult->setErr(0);
     }
     return $profileResult;
 }