微博api问题,大神进!

lcniuren33 发布于 2012/09/09 10:40
阅读 507
收藏 1

已经获取了腾讯微博有些用户的授权,也有access_token,但是发微博部分不知道怎么搞,这是我的js代码,求大神解释~~返回的总是鉴权失败。。

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>api</title>
<script src="//mat1.gtimg.com/app/openjs/openjs.js#debug=yes"></script>
<script language="JavaScript" type="text/javascript">
var http_request;
// 创建一个XMLHttpRequest对象
function createXMLHTTPRequext(){
if(window.ActiveXObject) {
http_request = new ActiveXObject('Microsoft.XMLHTTP');
}else if(window.XMLHttpRequest){
http_request = new XMLHttpRequest();
}
}
function PostOrder()
{
createXMLHTTPRequext();
http_request.open("POST","https://open.t.qq.com/api/t/add", true);
http_request.send("oauth_consumer_key=801234989&access_token=xxxxx&openid=xxxxxx&clientip=115.156.219.20&oauth_version=2.a&scope=all");
http_request.onreadystatechange= HandleStateChange; 
}
function HandleStateChange()
{
if (http_request.readyState == 4){
if (http_request.status == 200|| http_request.status == 0){
alert("succeed!");
                                T.init({appkey:801234989});
                                T.api("/t/add,{"content":"helloworld","clientip":"115.156.219.20"}, "json", "post")
                              .success(function (response){
                                              alert([response.data.nick,response.data.email]);
                                      })
                                     .error(function (code, message) {
                                          alert(message);
                                      });

                                }else if (http_request.status == 404 || http_request.status == 2){
alert("404 not found!");
}else{
alert("error occured while requesting data!("+http_request.status+") ");
}
}else{}
}
</script>
</head>
<body>
<input type="button" value="发送微博" onclick="PostOrder();"/>
</body>
</html> 

加载中
返回顶部
顶部