facebook - 如何在 iOS 6 中使用社交框架点赞 Facebook 页面/关注 Twitter 用户?

标签 facebook twitter ios6 facebook-like social-framework

有没有一种简单的方法可以在 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/

相关文章:

asp.net - 如何为我的网站实现 Facebook "Like"按钮

facebook - 使用 CloudMade 和 Facebook iOs SDK 时出现重复符号 _OBJC_METACLASS_$_SBJSON

使用 Open Graph 的 iOS Facebook 发布失败 - 错误代码 102

database-design - 您将如何使用 noSQL 类型的数据库来实现 twitter?

xcode - 在带有 Cordova 2.1 的 xcode 4.5 中启动图像不会更新

ios - 如何在 ios 6.1 xcode 4.6 中获取 json 数据

Facebook API : friends' hometown_location and current_location always empty using FQL

twitter - "Sneak peak"Twitter 帐户如何运作?

javascript - Twitter oauth 请求 token 上的 400 错误请求

ios - UICollectionView 单元配置次数过多