4、当放到线上的时候,选择相应的举办上线,首先要去平台“我的应用”配置回调地点,然后再授权地点上加上回调地点,还要举办授权去获取session,然后通过session去获取店肆的id
回调地点:
授权地点:
5、授权地点:
]
授权地点可以获取auth_code,按照这个值去调换session,调换session后可以去调换店肆id
//获取auth_code public function get_auth(){ $auth_code = input('auth_code'); if(!isset($auth_code)) { $app_key='1ef*****3a8'; $state='teststate'; $redirect_url='https://****/admin/Dian/get_auth'; $scope='tuangou'; $url='https://e.dianping.com/dz-open/merchant/auth?'; $data=[ 'app_key' =>$app_key, 'state' => $state, 'redirect_url' =>$redirect_url, 'scope' =>$scope, ]; $postdata = http_build_query($data); Header("Location: $url$postdata"); } else { var_dump($auth_code);die(); } } //获取session public function get_session(){ $app_key='1ef0*****e3a8'; $app_secret='dd8a291******bd9be6ff'; $auth_code='4e027519e******a6a9d1ee5f2'; $grant_type='authorization_code'; $redirect_url='https://*****/admin/Dian/get_auth'; $data=[ 'app_key' =>$app_key, 'app_secret' => $app_secret, 'redirect_url' =>$redirect_url, 'auth_code' =>$auth_code, 'grant_type' =>$grant_type ]; $postdata = http_build_query($data); $url='https://openapi.dianping.com/router/oauth/token'; $tmpInfo=$this->curl_post($url,$postdata); var_dump($tmpInfo); } //获取所有店肆的id public function get_shopid(){ $app_key='1ef04*****e3a8'; $secret = "dd8a29*****fbd9be6ff"; //秘钥 $sign_method='MD5'; $timestamp = date('Y-m-d H:i:s'); $format = 'json'; $v = 1; //$session = 'f44d594ab895c******85b70bade02c'; $session = 'bbf7059256aaf3*******0816cf819b7'; $bid='5da1aab********5ad457a2c';//和session一起返回的 $offset =0; $limit = 20; $url='https://openapi.dianping.com/router/oauth/session/scope?'; $data=[ 'app_key' =>$app_key, 'sign_method' => $sign_method, 'timestamp' =>$timestamp, 'format' =>$format, 'v' =>$v, 'session' =>$session, 'bid' =>$bid, 'offset' =>$offset, 'limit' =>$limit, ]; ksort($data); $sign = $this->cal_sign($secret, $data); $data['sign'] = $sign; $postdata = http_build_query($data); $tmpInfo=$this->curl_get($url.$postdata); var_dump($tmpInfo); }
到此这篇关于PHP 对接美团公共点评团购券(门票)的开拓步调的文章就先容到这了,更多相关PHP美团公共点评团购券内容请搜索剧本之家以前的文章或继承欣赏下面的相关文章但愿各人今后多多支持剧本之家!
您大概感乐趣的文章: