i'm using SLRequest with twitter, and until a few days ago everything worked fine with the code below but now the response is empty and the error description is null, this is the code i always use:
ACAccountStore *accountStoreTw = [[ACAccountStore alloc] init];
ACAccountType *accountTypeTw = [accountStoreTw accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[accountStoreTw requestAccessToAccountsWithType:accountTypeTw options:NULL completion:^(BOOL granted, NSError *error) {
if(granted) {
FMDatabase *db = [FMDatabase databaseWithPath:[self databasePath]];
if ([db open]) {
FMResultSet *tw_name_q = [db executeQuery:@"SELECT tw_username FROM settings WHERE id = 1"];
NSString *tw_name = @"";
while ([tw_name_q next]) {
tw_name = [tw_name_q stringForColumn:@"tw_username"];
}
if (![tw_name isEqualToString:@""]) {
NSArray *accountsArray = [accountStoreTw accountsWithAccountType:accountTypeTw];
for (ACAccount *tw_account in accountsArray) {
if ([[tw_account username] isEqualToString:tw_name]) {
SLRequest* twitterRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter
requestMethod:SLRequestMethodPOST
URL:[NSURL URLWithString:@"http://api.twitter.com/1/statuses/update.json"]
parameters:[NSDictionary dictionaryWithObject:msg_post forKey:@"status"]];
[twitterRequest setAccount:tw_account];
[twitterRequest performRequestWithHandler:^(NSData* responseData, NSHTTPURLResponse* urlResponse, NSError* error) {
NSLog(@"text response: %@", [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]);
NSLog(@"error: %@",error.localizedDescription);
NSString *output = [NSString stringWithFormat:@"HTTP response status: %i Error %d", [urlResponse statusCode],error.code];
NSLog(@"%@ error %@", output,error.description);
}];
break;
}
}
}
}
[db close];
}
}];
now this log give me this:
text response:
error: (null)
403 Error 0 error (null)
what is the problem? any idea to fix it?
There has been a recent change to the Twitter API. You can now only call it using HTTPS.
You should ensure that the URL you / your library is using starts with
https://api.twitter.com/1.1/
(Notice the extra s
after the http
.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With