欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

[IOS]新浪微博获取数据出错

程序员文章站 2022-06-26 15:15:46
...

保存access token后再次登陆获取home_timeline时

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObject:@"5" forKey:@"count"];
    [self.sinaweibo requestWithURL:@"statuses/home_timeline"
                            params:params
                        httpMethod:@"GET"
                          delegate:self];

 出现如下错误:

Error Domain=SinaWeiboSDKErrorDomain Code=200 "Data parse error" UserInfo=0x7589900 {NSLocalizedDescription=Data parse error, error=Error Domain=JKErrorDomain Code=-1 "Unexpected token, wanted '{', '}', '[', ']', ',', ':', 'true', 'false', 'null', '"STRING"', 'NUMBER'." UserInfo=0x7589a10 {JKAtIndexKey=0, JKLineNumberKey=1, NSLocalizedDescription=Unexpected token, wanted '{', '}', '[', ']', ',', ':', 'true', 'false', 'null', '"STRING"', 'NUMBER'.}} 

 原来发现是requestWithURL拼写错误,漏泄了后缀.json, 正确写法是:

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObject:@"5" forKey:@"count"];
    [self.sinaweibo requestWithURL:@"statuses/home_timeline.json"
                            params:params
                        httpMethod:@"GET"
                          delegate:self];

 

转载于:https://www.cnblogs.com/wisher/archive/2013/04/01/2992655.html