SLRequest 누군가가 나를 팔로우 할 수 있습니다. 이 기능은 iOS 5에서만 작동하지만 Facebook에서는 작동하지 않습니다.
이 배경 스레드에서 호출되어 있는지 확인 누군가가 트위터에 당신을 따라 할 SLRequest의 예 :
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) {
if (granted) {
// Get the list of Twitter accounts.
NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];
// For the sake of brevity, we'll assume there is only one Twitter account present.
// You would ideally ask the user which account they want to tweet from, if there is more than one Twitter account present.
if ([accountsArray count] > 0) {
// Grab the initial Twitter account to tweet from.
ACAccount *twitterAccount = [accountsArray objectAtIndex:0];
NSMutableDictionary *tempDict = [[NSMutableDictionary alloc] init];
[tempDict setValue:@"Your twitter name" forKey:@"screen_name"];
[tempDict setValue:@"true" forKey:@"follow"];
SLRequest *followRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:[NSURL URLWithString:@"https://api.twitter.com/1/friendships/create.json"] parameters:tempDict];
[followRequest setAccount:twitterAccount];
[followRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSString *output = [NSString stringWithFormat:@"HTTP response status: %i", [urlResponse statusCode]];
NSLog(@"%@", output);
if (error) {
dispatch_async(dispatch_get_main_queue(), ^{
//Update UI to show follow request failed
});
}
else {
dispatch_async(dispatch_get_main_queue(), ^{
//Update UI to show success
});
}
}];
}
}
}];
와 페이스 북에 대한 당신은 단지 그것의 일부를 변경하고 자신의 API를보고 있고 요청 URL을 변경하십시오.
버튼이 Facebook 로그인 세부 정보를 즉시 요청해야합니까? 아니면 Facebook 페이지를 회사 페이지에 열어야합니까? –
사용자가 이미 페이스 북에 로그인 한 경우 (iOS 내에서 지속될 수 있다고 가정), 페이스 북 페이지에 이미있는 것처럼 행동을 에뮬레이트하고 자동으로 좋아요 버튼을 클릭하게하고 싶습니다. 그래서 내가 추가 할 버튼 하나를 클릭하면 페이스 북 페이지를 자동으로 '좋아할 것'이라고 생각합니다. – dcb