protected function curl_post( $curlHttp, $postdata ) {
$ch = curl_init(); //用curl发送数据给api
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_URL, $curlHttp );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $postdata );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, FALSE );
$response = curl_exec( $ch );
curl_close( $ch );
$result = json_decode( $response, true );
return $result;
}
protected function buildRequestForm( array $param, $method, $target='',$jump=false) {
$sHtml = "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' /><form id='autoSubmit' action='".$target."' method='".$method."'>";
if ( !empty( $param ) ) {
foreach( $param as $key => $value ) {
$sHtml.= "<input type='hidden' name='".$key."' value='".urldecode($value)."'/>";
}
}
$sHtml .= "</form>";
if($jump) $sHtml = $sHtml."<script>document.getElementById(\"autoSubmit\").submit();</script>";
return $sHtml;
}
protectd function getAccessToken( $appId ) {
$accessToken = '';
if ( empty( $appId ) ) {
return $accessToken;
}
// 中间的逻辑自己填充
return $accessToken;
}
public function commitCode() {
$appId = input( 'app_id', '' );
$descript = input( 'descript', '测试代码指定' );
$version = input( 'version', 'V.1.0' );
$templateId = input( 'template_id', 1 );
if ( empty( $appId ) ) {
$this->error( appid不能为空 );
return;
}
if ( empty( $templateId ) && ( $templateId != 0 ) ) {
$this->error( '模板id不能为空' );
return;
}
$accessToken = $this->getAccessToken( $appId );
// 个人信息我给清除了,空字符部分请自己补充
$extJson = array(
'extAppid' => $appId,
'ext' => array(
'attr1' => 'value1'
),
'extPages' => array(
'pages/index/index' => array(
'navigationBarTitleText' => ''
),
'pages/media/media' => array(
'navigationBarTitleText' => ''
)
),
'pages' => array(
'pages/index/index',
'pages/media/media'
),
'window' => array(
'backgroundColor' => '#f8f8f8',
'navigationBarTextStyle' => 'white',
"navigationBarTitleText" => "",
'navigationBarBackgroundColor' => '#2b3b48'
),
'tabBar' => array(
'list' => array(
array(
'text' => '',
'pagePath' => 'pages/index/index',
),
array(
'text' => '',
'pagePath' => 'pages/media/media',
)
)
),
'networkTimeout' => array(
'request' => 10000,
'uploadFile' => 10000,
'downloadFile' => 10000,
'connectSocket' => 10000
)
);
$params = array(
'template_id' => $templateId,
'user_version' => $version,
'user_desc' => $descript,
'ext_json' => json_encode( $extJson, JSON_UNESCAPED_UNICODE )
);
$result = $this->curl_post( 'https://api.weixin.qq.com/wxa/commit?access_token='.$accessToken, json_encode( $params, JSON_UNESCAPED_UNICODE ) );
if ( empty( $result ) || !empty( $result['errcode'] ) ) {
$this->error( '代码指定错误' );
return;
}
$this->success( '操作成功' );
return;
}
public function getExpCode() {
$appId = input( 'app_id', '' );
if ( empty( $appId ) ) {
$this->error( appid不能为空 );
return;
}
$accessToken = $this->getAccessToken( $appId );
if ( empty( $accessToken ) ) {
$this->error( '获取授权accessToken错误' );
return;
}
$params = array(
'access_token' => $accessToken
);
$result = $this->buildRequestForm( $params, 'GET', 'https://api.weixin.qq.com/wxa/get_qrcode?access_token='.$accessToken, true );
echo $result;
exit;
}
public function bindTester() {
$appId = input( 'app_id', '' );
$wxNumber = input( 'wx_number', '' );
if ( empty( $appId ) ) {
$this->error( appid不能为空 );
return;
}
if ( empty( $wxNumber ) ) {
$this->error( 微信号不能为空 );
return;
}
$accessToken = $this->getAccessToken( $appId );
if ( empty( $accessToken ) ) {
$this->error( '获取授权accessToken错误' );
return;
}
$params = array(
'wechatid' => $wxNumber
);
$result = $this->curl_post( 'https://api.weixin.qq.com/wxa/bind_tester?access_token='.$accessToken, json_encode( $params ) );
print_r($result);
exit;
return;
}
public function unBindTester() {
$appId = input( 'app_id', '' );
$wxNumber = input( 'wx_number', '' );
if ( empty( $appId ) ) {
$this->error( appid不能为空 );
return;
}
if ( empty( $wxNumber ) ) {
$this->error( 微信号不能为空 );
return;
}
$accessToken = $this->getAccessToken( $appId );
if ( empty( $accessToken ) ) {
$this->error( '获取授权accessToken错误' );
return;
}
$params = array(
'wechatid' => $wxNumber
);
$result = $this->curl_post( 'https://api.weixin.qq.com/wxa/unbind_tester?access_token='.$accessToken, json_encode( $params ) );
print_r($result);
exit;
return;
}
public function getCategory() {
$appId = input( 'app_id', '' );
if ( empty( $appId ) ) {
$this->error( appid不能为空 );
return;
}
$accessToken = $this->getAccessToken( $appId );
if ( empty( $accessToken ) ) {
$this->error( '获取授权accessToken错误' );
return;
}
$params = array(
'access_token' => $accessToken
);
$result = $this->buildRequestForm( $params, 'GET', 'https://api.weixin.qq.com/wxa/get_category?access_token='.$accessToken, true );
echo $result;
exit;
}
public function submitAudit() {
$appId = input( 'app_id', '' );
if ( empty( $appId ) ) {
$this->error( appid不能为空 );
return;
}
$accessToken = $this->getAccessToken( $appId );
if ( empty( $accessToken ) ) {
$this->error( '获取授权accessToken错误' );
return;
}
$params = array(
'item_list' => array(
array(
'address' => 'pages/index/index',
'tag' => 'IT科技',
'first_class' => 'IT科技',
'second_class' => '硬件与设备',
'title' => '生成二维码'
),
array(
'address' => 'pages/media/media',
'tag' => '工具',
'first_class' => '工具',
'second_class' => '办公',
'title' => '多媒体上传'
)
)
);
$result = $this->curl_post( 'https://api.weixin.qq.com/wxa/submit_audit?access_token='.$accessToken, json_encode( $params, JSON_UNESCAPED_UNICODE ) );
echo'<pre>';
print_r($result);
exit;
$this->success( '操作成功' );
return;
}
public function getAuditStatus (){
$appId = input( 'app_id', '' );
if ( empty( $appId ) ) {
$this->error( appid不能为空 );
return;
}
$accessToken = $this->getAccessToken( $appId );
if ( empty( $accessToken ) ) {
$this->error( '获取授权accessToken错误' );
return;
}
$params = array(
'auditid' => 12334
);
$result = $this->curl_post( 'https://api.weixin.qq.com/wxa/get_auditstatus?access_token='.$accessToken, json_encode( $params ) );
print_r($result);
exit;
return;
}
public function release (){
$appId = input( 'app_id', '' );
if ( empty( $appId ) ) {
$this->error( appid不能为空 );
return;
}
$accessToken = $this->getAccessToken( $appId );
if ( empty( $accessToken ) ) {
$this->error( '获取授权accessToken错误' );
return;
}
$result = $this->curl_post( 'https://api.weixin.qq.com/wxa/release?access_token='.$accessToken, '{}' );
print_r($result);
exit;
return;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有