有沒有一種簡單的方法來喜歡Facebook頁面/關注Twitter用戶在iOS 6中使用社交框架?如何在iOS 6中使用社交框架來喜歡Facebook頁面/關注Twitter用戶?
我可以使用框架將消息發佈到用戶的Facebook/Twitter帳戶。
非常感謝您的幫助!
有沒有一種簡單的方法來喜歡Facebook頁面/關注Twitter用戶在iOS 6中使用社交框架?如何在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
應當指出的是,作爲iOS 6.0 TWRequest
已被棄用,支持社交框架中的SLRequest
,例如接受的答案爲:Twitter SLRequest performRequestWithHandler - Could not prepare the URL request
謝謝,這很有幫助。 – NullSleep
輕微更改,而不是TWRequest,現在您將使用SLRequest。 –