目标c -是否有可能在facebook上使用SLRequest在ios给朋友请求



我使用SLRequest获取用户详细信息并在facebook和twitter上分享。此外,我正在使用领英SDK和谷歌+ SDK来获取各自社交网络上的用户详细信息。我的问题是

  1. 有可能在facebook上使用SLRequest给朋友请求吗?
  2. 有可能在twitter上使用SLRequest跟踪一个人吗?
  3. 是否可以使用SDK连接领英上的人?
  4. 是否可以使用SDK在google+上添加一个人?
如果可能的话,请给我一个方法。谢谢。

经过很长时间,我找到了解决问题的方法,

  1. 对于Facebook图形api 2.0版本不支持好友请求(参考:https://developers.facebook.com/docs/dialogs/friends/v2.0)。

  2. 我们可以在twitter上这样做

    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:@"MohammadMasudRa" forKey:@"screen_name"];
            [tempDict setValue:@"true" forKey:@"follow"];
            NSLog(@"*******tempDict %@*******",tempDict);
            //requestForServiceType
            SLRequest *postRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:[NSURL URLWithString:@"https://api.twitter.com/1/friendships/create.json"] parameters:tempDict];
            [postRequest setAccount:twitterAccount];
            [postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
                NSString *output = [NSString stringWithFormat:@"HTTP response status: %i Error %d", [urlResponse statusCode],error.code];
                NSLog(@"%@error %@", output,error.description);
            }];
        }
    }
    

    }];

  3. 我们可以在Linkedin上这样做。

    NSURL *url = [NSURL URLWithString:@"http://api.linkedin.com/v1/people/~/mailbox"];
    OAMutableURLRequest *request =
    [[OAMutableURLRequest alloc] initWithURL:url
                                consumer:oAuthLoginView.consumer
                                   token:oAuthLoginView.accessToken
                                callback:nil
                       signatureProvider:nil];
    [request setHTTPMethod:@"POST"];
    NSString *messageToPerson = @"/people/email=test123@test.com";
    NSDictionary *person = [[NSDictionary alloc] initWithObjectsAndKeys:[[NSDictionary alloc] initWithObjectsAndKeys:messageToPerson,@"_path",@"test123",@"first-name",@"test",@"last-name",nil], @"person",nil];
    NSArray *valueArray = [[NSArray alloc] initWithObjects:person,nil];
    NSDictionary *values = [[NSDictionary alloc] initWithObjectsAndKeys:valueArray,@"values", nil];
    NSDictionary *ir = [[NSDictionary alloc] initWithObjectsAndKeys:[[NSDictionary alloc] initWithObjectsAndKeys:@"friend",@"connect-type",nil], @"invitation-request",nil];
    NSDictionary *update = [[NSDictionary alloc] initWithObjectsAndKeys:values,@"recipients",@"Invitation",@"subject",@"ConnectWithMe",@"body", ir, @"item-content", nil];
    [request setValue:@"json" forHTTPHeaderField:@"x-li-format"];
    [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    NSString *updateString = [update JSONString];
    [request prepare];
    [request setHTTPBodyWithString:updateString];
    OADataFetcher *fetcher = [[OADataFetcher alloc] init];
    [fetcher fetchDataWithRequest:request
                     delegate:self
            didFinishSelector:@selector(postUpdateApiCallResult1:didFinish:)
              didFailSelector:@selector(postUpdateApiCallResult1:didFail:) withPrepare:NO];
    
  4. 我无法获得有关google plus添加到圈子的详细信息。

最新更新