搜狐微博 API 相关问题
谁做过 搜狐微博 API 相关 例子。就是第三方以搜狐帐号登录,并获取用户资料。知道的,帮忙解答下面几个问题。
1、 搜狐微博 API ,获取登录者的用户资料。
2、我在自己电脑调用【http://api.t.sohu.com/oauth/access_token】 能正常登录,到Linux服务器下,部属运行就报如下错误。
java.io.IOException: Server returned HTTP response code: 400 for URL: http://api.t.sohu.com/oauth/access_token
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
at com.covics.weibo.server.SoHuWeiBo.getLogin(SoHuWeiBo.java:96)
at com.covics.weibo.BaseWeiBo.getLogin(BaseWeiBo.java:38)
at com.covics.weibo.BaseWeiBo.getLoginUserInfo(BaseWeiBo.java:59)
at com.covics.weibo.BaseWeiBo.getLoginUserInfo(BaseWeiBo.java:73)
at com.covics.meefon.service.member.WeiBoServer.checkSohuUser(WeiBoServer.java:186)
at com.covics.meefon.service.member.WeiBoServer.getWeiBoLogin(WeiBoServer.java:109)
at com.covics.meefon.service.member.WeiBoServer.weiBoSynchronous(WeiBoServer.java:67)
at com.covics.meefon.service.impl.Service_1_97.service(Service_1_97.java:48)
at com.covics.meefon.service.impl.AbstractBaseDataService.parseService(AbstractBaseDataService.java:206)
at com.covics.meefon.service.impl.FactoryServiceImpl.logicService(FactoryServiceImpl.java:101)
at com.covics.meefon.servlet.Portal.doPost(Portal.java:174)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:662)
--------------------编程问答-------------------- http://api.t.sohu.com/oauth/access_token 返回的什么值啊? json? --------------------编程问答--------------------
是搜狐微博的XAuth认证
下面是一个例子。
--------------------编程问答-------------------- --------------------编程问答-------------------- HTTP 400 貌似是 你的url在服务端不识别啊
public static void main(String[] args) throws Exception {
OAuthConsumer consumer = new DefaultOAuthConsumer(
"consumer_key", "consumer_secret");
URL url = new URL("http://api.t.sohu.com/oauth/access_token");
HttpURLConnection request = (HttpURLConnection) url.openConnection();
request.setDoOutput(true);
request.setRequestMethod("POST");
HttpParameters para = new HttpParameters();
para.put("x_auth_username", URLEncoder.encode("your_passport","utf-8"));
para.put("x_auth_password", "your_password");
para.put("x_auth_mode", "client_auth");
consumer.setAdditionalParameters(para);
consumer.sign(request);
OutputStream ot = request.getOutputStream();
ot.write(("x_auth_username="+URLEncoder.encode("your_passport","utf-8")+"&x_auth_password=your_password&x_auth_mode=client_auth").getBytes());
ot.flush();
ot.close();
System.out.println("Sending request...");
request.connect();
System.out.println("Response: " + request.getResponseCode() + " "
+ request.getResponseMessage());
BufferedReader reader =new BufferedReader(new InputStreamReader(request.getInputStream()));
String b = null;
while((b = reader.readLine())!=null){
System.out.println(b);
}
request.disconnect();
}
是不是 服务端的问题啊! --------------------编程问答-------------------- 瞄 下。。 --------------------编程问答--------------------
我想也是服务器的问题。因为我在我们开发电脑试了很多台。都正常登录···但到linux服务器就失败了。 --------------------编程问答--------------------
可就是不知道如何解决。 --------------------编程问答-------------------- ???没有知道。 --------------------编程问答-------------------- 我跟你一样,客户端都没问题,windows都ok
到了linux老是报错! --------------------编程问答-------------------- LZ,如果知道答案了告诉我一下
邮箱是:58132017@163.com --------------------编程问答-------------------- 楼主你好,我现在也急用这个项目不知道您实现了没有,如果实现了麻烦您发我一份。跪求啊。。这是我邮箱951963400@qq.com --------------------编程问答-------------------- 楼主麻烦给我也发一份我看看 我这一直报错 谢谢了 listlisc@163.com --------------------编程问答-------------------- 女孩脑子慢 --------------------编程问答-------------------- 楼主,我的也出错了,能不能发一份解决方案给我啊 670876068@qq.com --------------------编程问答-------------------- 我也要一份12362665@qq.com --------------------编程问答-------------------- 400 BAD REQUEST 请求的地址不存在或者包含不支持的参数
参数不对吧?
补充:Java , J2ME