有没有一种简单的方法可以在 iOS 6 中使用社交框架来喜欢 Facebook 页面/关注 Twitter 用户?
我可以使用该框架将消息发布到用户的 facebook/twitter 帐户。
最佳答案
这是在 Twitter 上关注用户的方法
-(void)followTwitter{
ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[account requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error)
{
NSLog(@"this is the request of account ");
if (granted==YES) {
NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType];
if ([arrayOfAccounts count] > 0)
{
// Keep it simple, use the first account available
ACAccount *acct = [arrayOfAccounts objectAtIndex:0];
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:@"FollowedUserNameHere",@"screen_name",@"TRUE",@"follow", nil];
TWRequest *request = [[TWRequest alloc] initWithURL:[NSURL URLWithString:@"https://api.twitter.com/1.1/friendships/create.json"] parameters:dictionary requestMethod:TWRequestMethodPOST];
[request setAccount:acct];
[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
{
if ([urlResponse statusCode] == 200)
{
// The response from Twitter is in JSON format
// Move the response into a dictionary and print
NSError *error;
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&error];
NSLog(@"Twitter response: %@", dict);
}
else
NSLog(@"Twitter error, HTTP response: %i", [urlResponse statusCode]);
}];
}
}
}];
}
并点击此链接来喜欢 Facebook 页面
http://angelolloqui.blogspot.jp/2010/11/facebook-like-button-on-ios.html
关于facebook - 如何在 iOS 6 中使用社交框架点赞 Facebook 页面/关注 Twitter 用户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13546948/