123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- namespace App\Http\Controllers\Wechat\Api;
- use App\Http\Controllers\WechatOpController;
- use Illuminate\Http\Request;
- use Illuminate\Http\Response;
- use EasyWeChat\Foundation\Application;
- use WechatOP;
- use GuzzleHttp\Client;
- use EasyWeChat\OpenPlatform\Api\BaseApi;
- /**
- * 三方相关api接口
- * @author zhoulingjie
- *
- */
- class WechatOpApisController extends WechatOpController
- {
-
- public function __construct(Request $request)
- {
- parent::__construct();
- }
-
- /**
- * 获取三方平台绑定的公众号列表
- * @param Request $request
- *
- http://zydy/api/get_authorizer_list?component_appid=wxceb2aacdce248393&component_access_token=17_hTuiGp6BoLl3OuC8qtJHocQOM2UjClJFnp-htHjKcXmTxNsl06M2c7SG7cJHWOgYwxPgfpeRIA-302-Rl_TxdV2X4YcDHKXbT-6Qk7oUlaGrF7e3TWxZgsT1p39XYUUWXfXUob7rIS6qjayrQTYhADAKNS
- */
- function get_authorizer_list(Request $request){
- $result = array('code'=>1,'msg'=>'','data'=>'');
- $component_appid = $request->get('component_appid');
- $component_access_token = $request->get('component_access_token');
- v('get_authorizer_list_start,component_appid:'.$component_appid.' $component_access_token:'.$component_access_token);
- if(empty($component_appid)){
- $result['code'] = 0;
- $result['msg'] = 'invalid param';
- json_echo($result);
- }
-
- $check_result = $this->check_sign_params($request);
- if($check_result['code'] == 0){
- $result['code'] = 0;
- $result['msg'] = $check_result['msg'];
- // json_echo($result);
- }
-
- // $authorizer_list = $this->openPlatform->getAuthorizerInfo('wxceb2aacdce248393');
- $authors = [];
- for($i=1;$i<4;$i++){
- $client = new Client();
- $form_params = [
- "component_appid"=>$component_appid,
- "count"=>500,
- "offset"=>($i-1)*500,
- ];
- v($form_params);
- $authorizer_list = $client->request("post","https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_list?component_access_token=".$component_access_token,
- ['json'=>$form_params,'connect_timeout' => 3]
- )->getBody()->getContents();
- $authorizer_list = json_decode($authorizer_list,true);
- v('$authorizer_list:'.$i);v($authorizer_list);
- if(!empty($authorizer_list['list'])){
- foreach($authorizer_list['list'] as $authorizer){
- $authors[] = $authorizer['authorizer_appid'];
- }
- }
- }
-
- $result['data'] = $authors;
- json_echo($result);
- }
-
- }
|