Giter VIP home page Giter VIP logo

weibo4j-oauth2-beta3.1.1's People

Contributors

sunxiaowei2014 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

weibo4j-oauth2-beta3.1.1's Issues

GetPublicTimeline数字格式错误

执行GetPublicTimeline样例的时候,获取GEO数据,报NumberFormatException异常。
weibo4j.model.Status.getGeoInfo(String)
内部当做 {"coordinates":[34.285431,107.7343647]} 格式处理,
实际格式为 {"coordinates":[34.285431,107.7343647],"type":"Point"}
由于后面对,判断的代码,导致 维度数据被经度数据覆盖而丢失,而经度数据格式错误出现异常。

将代码改为:
private void getGeoInfo(String geo) {
StringBuffer value= new StringBuffer();
for(char c:geo.toCharArray()){
if(c>45&&c<58){
value.append(c);
}
if(c==44){
if(value.length()>0){
latitude=Double.parseDouble(value.toString());
value.delete(0, value.length());
}
}else if(c == ']'){
longitude=Double.parseDouble(value.toString());
break;
}
}
}
故障排除。

地理位置解析出错

在获取微博时的地理位置解析出错
在Status.java文件中

private void getGeoInfo(String geo) {
    StringBuffer value = new StringBuffer();
    for (char c : geo.toCharArray()) {
        if (c > 45 && c < 58) {
        value.append(c);
        }
        if (c == 44) {
        if (value.length() > 0) {
            latitude = Double.parseDouble(value.toString());
            value.delete(0, value.length());
        }
        }
    }
    longitude = Double.parseDouble(value.toString());
    }

修改为

 if (c == 44) {
        if (value.length() > 0 && latitude == -1) {
            latitude = Double.parseDouble(value.toString());
            value.delete(0, value.length());
        }

授权成功获取到accessToken后我再次使用uid去请求用户信息报错

返回的用户消息如下:
{"id":2094216050,"idstr":"2094216050","class":1,"screen_name":"鱼鱼爱上水","name":"鱼鱼爱上水","province":"31","city":"14","location":"上海 嘉定区","description":"","url":"","profile_image_url":"http://tp3.sinaimg.cn/2094216050/50/0/1","profile_url":"u/2094216050","domain":"","weihao":"","gender":"m","followers_count":0,"friends_count":0,"pagefriends_count":0,"statuses_count":0,"favourites_count":0,"created_at":"Wed Jan 04 18:36:27 +0800 2012","following":false,"allow_all_act_msg":false,"geo_enabled":true,"verified":false,"verified_type":-1,"remark":"","status":{},"ptype":0,"allow_all_comment":true,"avatar_large":"http://tp3.sinaimg.cn/2094216050/180/0/1","avatar_hd":"http://tp3.sinaimg.cn/2094216050/180/0/1","verified_reason":"","verified_trade":"","verified_reason_url":"","verified_source":"","verified_source_url":"","follow_me":false,"online_status":1,"bi_followers_count":3,"lang":"zh-cn","star":0,"mbtype":0,"mbrank":0,"block_word":0,"block_app":0,"credit_score":80}
报错的原因是json解析status内的内容报空指针异常!

OAuth4Code.java got javax.net.ssl.SSLHandshakeException

DEBUG [2021-07-16 12:47:40] POSThttps://api.weibo.com/oauth2/access_token
weibo4j.model.WeiboException: Received fatal alert: handshake_failure
at weibo4j.http.HttpClient.httpRequest(HttpClient.java:412)
at weibo4j.http.HttpClient.post(HttpClient.java:293)
at weibo4j.Oauth.getAccessTokenByCode(Oauth.java:79)
at weibo4j.examples.oauth2.OAuth4Code.main(OAuth4Code.java:21)
Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
at com.ibm.jsse2.j.a(j.java:39)
at com.ibm.jsse2.j.a(j.java:17)
at com.ibm.jsse2.qc.b(qc.java:463)
at com.ibm.jsse2.qc.a(qc.java:482)
at com.ibm.jsse2.qc.h(qc.java:272)
at com.ibm.jsse2.qc.a(qc.java:52)
at com.ibm.jsse2.h.write(h.java:10)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:93)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:151)
at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:506)
at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
at weibo4j.http.HttpClient.httpRequest(HttpClient.java:387)
... 3 more

运行代码出现error:redirect_uri_mismatch

运行新浪提供的Java示例出现此错误:

问题:
此错误表示在本地config.properties里填写的redirect_URI与微博开放平台上应用的设置不一致。
image1

解决办法:
登录微博开放平台http://open.weibo.com,然后点击:我的应用 -> {应用名字} -> 应用信息 -> 高级信息。然后编辑OAuth2.0 授权设置:
image2

请确保授权回调页和本地Config.properties里的redirect_URI项的值一致。

登录和授权都成功, 但取不到accessToken

以下是日志:
https://api.weibo.com/oauth2/authorize?client_id=xxxxxxxxxx&redirect_uri=https://api.weibo.com/oauth2/default.html&response_type=code
Hit enter when it's done.[Enter]:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
0 INFO [2014-10-11 22:14:20] code:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2 DEBUG [2014-10-11 22:14:20] Request:
2 DEBUG [2014-10-11 22:14:20] POSThttps://api.weibo.com/oauth2/access_token
1209 DEBUG [2014-10-11 22:14:21] Response:
1209 DEBUG [2014-10-11 22:14:21] https StatusCode:401
1210 DEBUG [2014-10-11 22:14:21] Server:nginx/1.2.0
1210 DEBUG [2014-10-11 22:14:21] Date:Sat, 11 Oct 2014 14:13:29 GMT
1210 DEBUG [2014-10-11 22:14:21] Transfer-Encoding:chunked
1210 DEBUG [2014-10-11 22:14:21] Connection:keep-alive
1210 DEBUG [2014-10-11 22:14:21] Pragma:No-cache
1210 DEBUG [2014-10-11 22:14:21] Cache-Control:no-cache
1210 DEBUG [2014-10-11 22:14:21] Expires:Thu, 01 Jan 1970 00:00:00 GMT
1211 DEBUG [2014-10-11 22:14:21] Api-Server-IP:10.73.89.48
1215 WARN [2014-10-11 22:14:21] Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.
1216 DEBUG [2014-10-11 22:14:21] {"error":"invalid_client","error_code":21324,"request":"/oauth2/access_token","error_uri":"/oauth2/access_token","error_description":"client_secret error."}

weibo4j.model.WeiboException : 401:Authentication credentials were missing or incorrect.
error:invalid_client error_code:21324/oauth2/access_token
1222 INFO [2014-10-11 22:14:21] Unable to get the access token.
at weibo4j.http.HttpClient.httpRequest( HttpClient.java:403)
at weibo4j.http.HttpClient.post( HttpClient.java:293)
at weibo4j.Oauth.getAccessTokenByCode( Oauth.java:79)
at weibo4j.examples.oauth2.OAuth4Code.main( OAuth4Code.java:21)

问题所在:
config.properties里的client_ID和client_SERCRET的值中空格

解决办法:
删除值前后的空格,保证client_ID和client_SERCRET与微博开放平台上你应用基本信息的App Key和 App Secret一致。

AccessToken

AccessToken类写的有问题,uid没暴露get方法,hashCode,equals方法覆盖都有问题,不知道是不是uid这个属性是不是后加的

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.