我想将用户的位置附加到TWRequest。我试着修改url (类似于:"http://api.twitter.com/1/statuses/update.json?lat=37.76893497&long=-122.42284884"),但得到的响应是"401未授权“或”400Bad Request“。
我的TWRequest:
TWRequest *postRequest = [[TWRequest alloc] initWithURL:
[NSURL URLWithString:@"http://api.twitter.com/1/statuses/update.json"] parameters:[NSDictionary dictionaryWithObject:[tweet text] forKey:@"status"] requestMethod:TWRequestMethodPOST];提前谢谢。
发布于 2012-01-08 20:26:05
您尝试执行需要授权的请求。只需初始化帐户属性即可。看看一篇关于Twitter API的好文章:http://iosdevelopertips.com/core-services/ios-5-twitter-framework-part-2.html
URL更新:你不能混合POST和GET变量,我的意思是你必须指定所有的参数给NSDictionary (POST参数),而不是指定给。
NSURL *updateURL = [NSURL URLWithString:@"http://api.twitter.com/1/statuses/update.json"];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[tweet text], @"status",
@"-122.42284884", @"long",
@"37.76893497", @"lat", nil];
TWRequest *postRequest = [[TWRequest alloc] initWithURL:updateURL
parameters:dict
requestMethod:TWRequestMethodPOST];UPD2:如果地理位置不起作用,检查推特帐户是否启用了位置(转到推特网站-设置-帐户-推文位置)。看看推特网站update request section上的REST API documentation:
关于geo
如果用户的geo_enabled为false (这是所有用户的默认设置,除非用户在其设置中启用了地理位置),则更新中的所有地理标注参数都将被忽略
https://stackoverflow.com/questions/8777370
复制相似问题