我正在为iPhone建立一个Twitter客户端,并且正在使用OAuth验证对Twitter的请求,
现在,我能够获得本地时间线,甚至发布推文(不包含任何空格或符号),当我尝试发布包含空格的推文时,问题就开始了,例如,它给了我:{“error”:“签名不正确“,” request“:” \ / 1 \ / statuses \ /update.json“}
例如,tweet:“ThisIsATweet”有效,但tweet:“this is tweet”不起作用
这是我的http请求正文代码:
NSData* body =[NSString stringWithFormat:@"status=%@",[self percentageEncoding:tweet]];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setValue:[NSString stringWithFormat:@"%d",[body length]] forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:[body dataUsingEncoding:NSISOLatin1StringEncoding]];
最佳答案
首先使用stringByAddingPercentEscapesUsingEncoding:
转义字符串。
关于objective-c - 使用IOS应用中的OAuth发布推文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6160562/