Heim  >  Artikel  >  Backend-Entwicklung  >  微信开放平台 - PHP微信登录授权问题

微信开放平台 - PHP微信登录授权问题

WBOY
WBOYOriginal
2016-06-06 20:25:511902Durchsuche

关于登录授权问题,我index.php中代码
header('location:https://open.weixin.qq.com/connect/oauth2/authorize?appid=我的appid&redirect_uri=192.168.1.127%2foauth2.php&response_type=code&scope=snsapi_login&state=1#wechat_redirect');
然后在微信中打开192.168.1.127,根据代码会跳转到微信授权页面,授权成功后按照我的理解应该会跳转到192.168.1.127/oauth.php&code=xxxxxx&state=xxx,但是没有跳转过去,而是跳转到
https://open.weixin.qq.com/connect/oauth2/192.168.1.127/oauth.php?code...;问下这是怎么回事呢?

回复内容:

关于登录授权问题,我index.php中代码
header('location:https://open.weixin.qq.com/connect/oauth2/authorize?appid=我的appid&redirect_uri=192.168.1.127%2foauth2.php&response_type=code&scope=snsapi_login&state=1#wechat_redirect');
然后在微信中打开192.168.1.127,根据代码会跳转到微信授权页面,授权成功后按照我的理解应该会跳转到192.168.1.127/oauth.php&code=xxxxxx&state=xxx,但是没有跳转过去,而是跳转到
https://open.weixin.qq.com/connect/oauth2/192.168.1.127/oauth.php?code...;问下这是怎么回事呢?

redirect_uri 应该需要带 scheme, http://example.com/foo.php

在微信公众号请求用户网页授权之前,开发者需要先到公众平台官网中的开发者中心页配置授权回调域名。请注意,这里填写的是域名(是一个字符串),而不是URL,因此请勿加http://等协议头;----微信开发文档关于网页授权回调域名的说明的第一条

你的回调地址没有加 http://

回调地址请使用标准的 URL 地址:http(s)://subdomain.domain.com/segment1/setment2/setmentn...

  1. redirect_uri 应该需要带 scheme, http://www.example.com/auth.php

  2. 需要在公众平台 开发者中心配置网页授权的域名,注意这里的域名就是上面的example.com

不能用ip...

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn