我想通过单击按钮关注Twitter用户。我使用共享工具包按照我的方法使用oauth。但总是我得到这个错误。iPhone在twitter上关注用户编程
{ “错误”: “无法与 OAuth的身份验证。”, “请求”: “/ 1 /友谊/创建/ priyankav89.json”}
然后我试图实现它我自己
NSURL *url = [NSURL URLWithString:@"https://api.twitter.com/1/friendships/create.json"];
NSMutableDictionary *dict=[[NSMutableDictionary alloc]init];
[dict setObject:@"871252998" forKey:@"user_id"];
[dict setObject:@"true" forKey:@"follow"];
[dict setObject:@"KXL0jFLJY6RI4lszOz8r5w" forKey:@"consumer"];
NSString *jsonRepresentation=[dict JSONString];
NSLog(@"jsonRepresentation = %@",jsonRepresentation);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:3];
NSData *postData=[NSData dataWithBytes:jsonRepresentation.UTF8String length:[jsonRepresentation length]];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:[NSString stringWithFormat:@"%d", [postData length]] forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:postData];
NSURLResponse *response;
NSError *error=nil;
NSData *responseData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSLog(@"respon = %s",responseData.bytes);
仍然我得到相同的错误。
我搜索了很多。仍然没有用。我不想在UIWebView或Safari浏览器中加载网址。我想支持来自ios4的应用程序。所以ios5内置twitter应用程序无法使用。
您是否使用了sharekit使用或不? –
我尝试了分享工具包,请按照我的方法进行推特。但它不工作。我正在使用共享工具来共享正在工作的文本。 –
简而言之,你想在Twitter上分享什么? –