I want to connect to the Facebook Login through api, I can Login and get information but everything is from Facebook:
here is my code how can I write this code return [FBSession.activeSession handleOpenURL:url]; to
return [[[HttpRequest sharedHttpRequest] session] handleOpenURL:url];
I should have session.activeSession, but if I right it like this I will have an error
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
{
//return [FBSession.activeSession handleOpenURL:url];
// return [[[HttpRequest sharedHttpRequest] session] handleOpenURL:url];
}
would you please help me to implement this method,
Thanks in advance!
UPDATE : It never use the url and stringByAppendingString:@"connect-fb"
I can login and I can get information but it never use api for example it works with this NSString *url = [BASE_URL stringByAppendingString:@"connect-fb"]; and also if I put what ever I want in stringByAppendingString:@"everything"
Here is my method for login and connect to api:
-(void) getApiUserInfos
{
if (FBSession.activeSession.isOpen) {
[[FBRequest requestForMe] startWithCompletionHandler:
^(FBRequestConnection *connection,
NSDictionary<FBGraphUser> *user,
NSError *error) {
if (!error) {
NSString *url = [BASE_URL stringByAppendingString:@"connect-fb"];
NSLog(@"%@",url);
NSString *post = [NSString
stringWithFormat:@"facebookId=%@&firstName=%@&lastName=%@&email=%@",
self.facebookId = user.id,
self.firstName= user.first_name,
self.lastName= user.last_name,
self.email=user.email];
NSLog(@"post : %@",post);
post = [post stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSData *postData = [NSData dataWithBytes: [post UTF8String] length: [post
lengthOfBytesUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL
URLWithString:url]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:600];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:postData];
[NSURLConnection sendAsynchronousRequest:request queue:[[NSOperationQueue
alloc] init]
completionHandler:
^(NSURLResponse *response, NSData *data, NSError *error) {
return;
if(error)
{
NSLog(@"Errorr");
}
///write for if error
NSString *ret = [NSString stringWithUTF8String:[data bytes]];
NSLog(@"api yser infos RETSTRING : %@",ret);
}];
}
}];
}