moafmoar / weibo4j

Automatically exported from code.google.com/p/weibo4j
Other
0 stars 0 forks source link

空指针异常 #3

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.  执行 weibo4j.examples.timeline.GetPublicTimeline
2.  Weibo.java 2371行  get(url, null, authenticate);
3.  Weibo.java 2416行  if(0!=params.length)

What is the expected output? What do you see instead?
Weibo.java 2416行  if(0!=params.length) 
需处理空指针异常

What version of the product are you using? On what operating system?
weibo4j-1.2.1.zip 

Please provide any additional information below.

Original issue reported on code.google.com by helinxi...@gmail.com on 23 Aug 2011 at 7:47

GoogleCodeExporter commented 8 years ago
已经处理

重新上传,请下载

多谢反馈

Original comment by haidong...@gmail.com on 23 Aug 2011 at 9:59

GoogleCodeExporter commented 8 years ago
Weibo.java  838 行 getPublicTimeline() 方法有错误,

public List<Status> getPublicTimeline() throws
    WeiboException {
        return Status.constructStatuses(get(getBaseURL() +
                "statuses/public_timeline.json", true));
    }

修改成以下方式可以工作:

public List<Status> getPublicTimeline() throws
    WeiboException {
        return Status.constructStatuses(get(getBaseURL() +
                "statuses/public_timeline.json", 
                new PostParameter[]{
            new PostParameter("source", Weibo.CONSUMER_KEY)
        }, true));
    }

Original comment by helinxi...@gmail.com on 23 Aug 2011 at 11:08

GoogleCodeExporter commented 8 years ago
     这里判断有误造成的,修改如下即可。
     protected Response get(String url, PostParameter[] params, boolean authenticate) throws WeiboException {
        if (null!= params && params.length >0) {
            String encodedParams = HttpClient.encodeParameters(params);
            if (-1 == url.indexOf("?")) {
                url += "?" + encodedParams;
            } else {
                url += "&" + encodedParams;
            }
        }
        return http.get(url, authenticate);
    }

Original comment by haidong...@gmail.com on 24 Aug 2011 at 1:30