我有应用程序在其中进行 Twitter 集成。
我能够成功发推文。
现在,当我想停用时,我在下面使用。
SLRequest *postRequest1 = [SLRequest requestForServiceType:SLServiceTypeTwitter
requestMethod:SLRequestMethodPOST URL:
[NSURL URLWithString:@"https://api.twitter.com/1/account/end_session.json"]
parameters: [NSDictionary dictionaryWithObject:@"" forKey:@"status"]];
问题是 1 的 API 已被弃用,我在 1.1 中找不到此方法。
有什么替代品吗?
我还注意到,当我再次尝试激活时,不会询问许可。它直接发送推文。它仅第一次请求推文许可。停用后不--重新激活过程。这就是 Twitter 的行为方式吗?
编辑 1
我用于所有推文的代码如下...
if ([self userHasAccessToTwitter]) {
ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
// Request access from the user to access their Twitter account
[account requestAccessToAccountsWithType:accountType options:NULL completion:^(BOOL granted, NSError *error)
{
if (granted == YES)
{
///////////////////////////////////////////////
// SEND TEXT ONLY ///
///////////////////////////////////////////////
[[NSUserDefaults standardUserDefaults] setValue:@"yes" forKey:@"twitterLogin"];
[[NSUserDefaults standardUserDefaults] synchronize];
// Populate array with all available Twitter accounts
NSString *message1 = [NSString stringWithFormat:@"Hi! I am using twitter integration."];
NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType];
if ([arrayOfAccounts count] > 0)
{
//use the first account available
ACAccount *acct = [arrayOfAccounts objectAtIndex:0];
SLRequest *postRequest1 = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:[NSURL URLWithString:@"http://api.twitter.com/1.1/statuses/update.json"] parameters: [NSDictionary dictionaryWithObject:message1 forKey:@"status"]];
[postRequest1 setAccount:acct];//set account
[postRequest1 performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
if(error) {
NSLog(@"error == %@", error);
} else {
NSLog(@"good to go -1- %i", [urlResponse statusCode]);
}
}];
}
}
}];
}