示例#1
0
 /**
  * @param ShakeAroundClient $shakeAroundClient
  * @param array $ids,本地主键id
  * @throws \Exception
  */
 public function deletePageOnline(ShakeAroundClient $shakeAroundClient, array $ids, $appid = null, $appsecret = null)
 {
     foreach ($ids as $v) {
         if (!WeixinPage::find($v)) {
             throw new \Exception(sprintf('page id %s not found', $v), 23001);
         }
     }
     $accessToken = $this->getWeixinToken($appid, $appsecret);
     if ($accessToken == NULL) {
         throw new \Exception("weixin get token error", 90000);
     }
     foreach ($ids as $k => &$v) {
         $ids[$k] = WeixinPage::find($v)->page_id;
     }
     $ret = $shakeAroundClient->deletePageByIds(['page_ids' => $ids], $accessToken);
     if ($ret->errcode != 0) {
         throw new \Exception('weixin error' . $ret->errmsg, 90000);
     }
 }