Question

I am using SLRequest to get user details and sharing on facebook and twitter. Also i am using Linkedin SDK and Google+ SDK to get user details on respective social networks. My questions are

  1. Is it possible to give friend request on facebook using SLRequest?
  2. Is it possible to follow a person on twitter using SLRequest?
  3. Is it possible to connect a person on linkedin using SDK?
  4. Is it possible to add a person on google+ using SDK?

if possible please give me a way to do that. Thanks.

Was it helpful?

Solution

After a long time, found the solution to my question,

  1. For Facebook graph api version 2.0 does not support friend request (Refer:https://developers.facebook.com/docs/dialogs/friends/v2.0).

  2. we can do it with twitter as follows

    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. We can do it with Linkedin as follows.

    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. I unable to get details abt google plus add to circle.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top