杭州神话信息技术有限公司

标题: 无法用java 客户端发微博,请fox大神帮忙看一下吧 [打印本页]

作者: 朴实的面包    时间: 2013-3-14 18:26:50     标题: 无法用java 客户端发微博,请fox大神帮忙看一下吧

几天前装了记事狗微博,但一直无法获取access token。经过一番摸爬滚打,终于取到token了,但是现在又无法发微博。苦啊。

String URL = "http://9.115.199.151/jsg4/api.php?mod=topic&code=add";
        
        JSONObject apiObject = new JSONObject();
        List<NameValuePair> nvps = new ArrayList<NameValuePair>();
        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(URL);        
        ResponseHandler<String> responseHandler = new BasicResponseHandler();
        
        // nvps.add(new BasicNameValuePair("", ""));
        nvps.add(new BasicNameValuePair("mod", "topic"));
        nvps.add(new BasicNameValuePair("code", "add"));
        nvps.add(new BasicNameValuePair("content", "this is one test"));
//        nvps.add(new BasicNameValuePair("totid", ""));
//        nvps.add(new BasicNameValuePair("type", "first"));
//        nvps.add(new BasicNameValuePair("item", ""));
//        nvps.add(new BasicNameValuePair("item_id", ""));
//        nvps.add(new BasicNameValuePair("pic_url", ""));
//        nvps.add(new BasicNameValuePair("pic", ""));
        
        // apiObject.put("", "");        
//        apiObject.put("charset", "utf-8");
//        apiObject.put("output", "json");
        apiObject.put("app_key", "6afc3487673827f3d8ad62ac2d6e0ea2");
//        apiObject.put("app_secret", "cbe2fae5a1009340a38b27ecb630f38a");
//        apiObject.put("username", "admin");
//        apiObject.put("password", "icmadmin");
        apiObject.put("auth_type", "oauth2");
//        apiObject.put("auth_sign", "");
        apiObject.put("access_token", "f45ef147c50506aee3ac3b76f0a52583");
        
        nvps.add(new BasicNameValuePair("__API__", apiObject.toString()));
System.out.println(apiObject.toString());
        
        httpPost.setEntity(new UrlEncodedFormEntity(nvps));
        String str1 = httpClient.execute(httpPost, responseHandler);
        System.out.println(str1);
        
        try {
//            System.out.println(response.getStatusLine());

            // do something useful with the response body
            // and ensure it is fully consumed
//            EntityUtils.consume(entity);
        } finally {
            httpPost.releaseConnection();
        }

系统返回:
<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
    <status><![CDATA[error]]></status>
    <error><![CDATA[1]]></error>
    <code><![CDATA[13]]></code>
    <result><![CDATA[app_key is invalid]]></result>
</root>

但我确认这个app_key是正确的啊。


AppKey
AppSecret
(日/周/月/年/总)请求数
上(日/周/月/年/)请求数
状态其他操作
  Test  6afc3487673827f3d8ad62ac2d6e0ea2
cbe2fae5a1009340a38b27ecb630f38a

求fox大神帮忙看一下吧?实在无解了。



作者: 朴实的面包    时间: 2013-3-14 18:27:07

自己顶一下。

作者: q151717    时间: 2013-3-15 14:59:37

看不懂啊。
作者: q151717    时间: 2013-3-15 14:59:56

都是些代码,和ASP的相差太远
作者: 朴实的面包    时间: 2013-3-18 09:01:31

q151717 发表于 2013-3-15 14:59
都是些代码,和ASP的相差太远

多谢关注,这些天就hang这里了





欢迎光临 杭州神话信息技术有限公司 (http://www.cenwor.com/) Powered by Discuz! X2