承接大中小型网站项目
1. 大中小型网站设计、开发与维护(电子商务网站、企业网站、门户网站...)
2. Flash设计、制作与维护
3. 重构网站前端为DIV+CSS
4. 优化数据库
5. 服务器维护
更多详细介绍...
官方网站: http://www.jejemf.com
E-mail: jlj508@gmail.com
QQ:
博客最新日志
给新年的自己
距离上一次写博客已经有两个多月。 作为新年的第一篇博客,我想...
很好的一部短片Alone In N...
非常好的一部短片,这是我在JW Player上看到的,觉得特别好,所...
腾讯开放平台——client i...
今天心血来潮想借腾讯的开放平台熟悉oauth。结果就摆弄了起来,...
好歌一起听——When You S...
很好听的歌,我喜欢,推荐听之。点击查看全文可以看歌词哦~ ...
华丽转身:博客使用新主题...
感谢裆,感谢国家,博客使用了新的主题——color. 已经是合并上...
更多腾讯开放平台——client id is illegal(100008)!错误解决
腾讯开放平台——client id is illegal(100008)!错误解决

今天心血来潮想借腾讯的开放平台熟悉oauth。结果就摆弄了起来,腾讯的文档还是写得很详细的,比我上一次看的已经好很多了。而且还提供了sdk,可以快速调用腾讯的开放平台,既然是学习来的,也就没图快,决定从零开始,手写代码。
一切都是按文档来的,可没想到第一步取access token就受挫了:
代码如下:
- function get_access_token() {
- var req_url = ‘ https://graph.qq.com/oauth2.0/authorize‘;
- var req_data = {
- ‘response_type‘: ‘token‘,//授权类型,此值固定为“token”
- ‘client_id‘: ‘201981‘, //申请QQ登录成功后,分配给应用的appid。
- ‘redirect_uri‘: ‘http://www.goodje.com/labs/login/qq_login.php‘, //成功授权后的回调地址,建议设置为网站首页或网站的用户中心。
- /*
- 请求用户授权时向用户显示的可进行授权的列表。
- 可填写的值是【QQ登录】API文档中列出的接口,以及一些动作型的授权(目前仅有:do_like),如果要填写多个接口名称,请用逗号隔开。
- 例如:scope=get_user_info,list_album,upload_pic,do_like
- 不传则默认请求对接口get_user_info进行授权。
- 建议控制授权项的数量,只传入必要的接口名称,因为授权项越多,用户越可能拒绝进行任何授权。
- */
- ‘scope‘: ‘get_user_info‘,
- ‘state‘: ‘comeonbb‘//client端的状态值。用于第三方应用防止CSRF攻击,成功授权后回调时会原样带回。
- //’display’: ‘mobile’//用于展示的样式。不传则默认展示为为PC下的样式。如果传入“mobile”,则展示为mobile端下的样式
- }
- window.open(req_url + ‘?‘ + buildHttpData(req_data));
- }
buildHttpData是我自定义的函数,用于把一个js对象转化为格式化的url参数。返回值为 {时间戳}&name1=value1&name2=value2&…
然后拼接req_url 后为: https://graph.qq.com/oauth2.0/authorize?1320327350000&response_type=token&client_id=201981&redirect_uri=http%3A%2F%2Fwww.goodje.com%2Flabs%2Flogin%2Fqq_login.php&scope=get_user_info&state=comeonbb
结果,就有了刚才那种情况了
后来分析了半天,网上也完全找不到解决办法,对比了文档上url的格式,发现除了多了时间戳外一点区别都没有,我想了下可能是参数必须是name=value的形式,服务端才能认识吧,因为url中有这么一段:?1320327350000&
而时间戳主要是之前为了防止ajax请求时读到缓存,所以才自动加上的,以前是从来都没有问题的,去掉了时间戳后,还不行,急了,仔细一看url,参数部分最前头还有个&,去了之后,好了,擦。。。
正确的获取access token url为:https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=201981&redirect_uri=http%3A%2F%2Fwww.goodje.com%2Flabs%2Flogin%2Fqq_login.php&state=comeonbb
而如果把时间戳或者任意一段字符串(只要是url中允许存在的字符,而且不是name=value的形式)放到url末尾,也会有问题
如:https://graph.qq.com/oauth2.0/authorize?response_type=token&client_id=201981&redirect_uri=http%3A%2F%2Fwww.goodje.com%2Flabs%2Flogin%2Fqq_login.php&scope=get_user_info&state=comeonbb&1320327350000
会报lost which in paraml(1000028)!错误
看了下响应头,server: tnginx
tnginx, 腾讯二次开发并优化过的nginx。难道优化的时候去掉了啥东西么,我记得nginx不会这样的呀,理论上这是腾讯的一个bug,不说了,反正是很坑爹的。
Lorem Ipsum is simply dum
industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknow the industry's standard dummy text ever since the 1500s
It was popularisedLorem Ipsum is simply dum
industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknow the industry's standard dummy text ever since the 1500s
It was popularisedLorem Ipsum is simply dum
industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknow the industry's standard dummy text ever since the 1500s
It was popularised
There are many variations
If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet.
It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to
It was popularised