1

I Get the access token from the following

    if ([FriendPeekerAppDelegate sharedDelegate].session.isOpen)
        {

        }
        else
        {
           [FriendPeekerAppDelegate sharedDelegate].session = [[FBSession alloc] init];
           [[FriendPeekerAppDelegate sharedDelegate].session openWithCompletionHandler:^(FBSession *session,
                                                                                          FBSessionState status,
                                                                                          NSError *error) 
    {
                // and here we make sure to update our UX according to the new session state
                [self updateView];
            }];


- (void)updateView
{

    if ([FriendPeekerAppDelegate sharedDelegate].session.isOpen)
 {
        accessToken = [NSString stringWithFormat:@"https://graph.facebook.com/me/friends?access_token=%@",
                                      [FriendPeekerAppDelegate sharedDelegate].session.accessTokenData.accessToken];
        if (accessToken != nil)
        {
            self.accessToken = accessToken;
        }

        if ( (callbackObject != nil) && (callbackSelector != nil) )
        {
         [callbackObject performSelector:callbackSelector];
        }


    }
    else
    {

    }
}

and then i want response for

-(void)getMyInfo
{
FbGraphResponse *fb_graph_response = [self.fbGraph doGraphGet:@"me" withGetVars:nil];
    NSString *tempStr = (NSString *)[fb_graph_response.htmlResponse retain];
    id dict = [[CheckConnectionAndJsonParing singleton]jsonToFoundationRepresentation:tempStr];
}


- (FbGraphResponse *)doGraphGet:(NSString *)action withGetVars:(NSDictionary *)get_vars {

    NSString *url_string = [NSString stringWithFormat:@"https://graph.facebook.com/%@?", action];

    //tack on any get vars we have...
    if ( (get_vars != nil) && ([get_vars count] > 0) ) {

        NSEnumerator *enumerator = [get_vars keyEnumerator];
        NSString *key;
        NSString *value;
        while ((key = (NSString *)[enumerator nextObject])) {

            value = (NSString *)[get_vars objectForKey:key];
            url_string = [NSString stringWithFormat:@"%@%@=%@&", url_string, key, value];

        }//end while    
    }//end if

    if (accessToken != nil) {
        //now that any variables have been appended, let's attach the access token....
        url_string = [NSString stringWithFormat:@"%@access_token=%@", url_string, self.accessToken];
    }

    //encode the string
    url_string = [url_string stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    return [self doGraphGetWithUrlString:url_string];
}

- (FbGraphResponse *)doGraphGetWithUrlString:(NSString *)url_string {

    FbGraphResponse *return_value = [[[FbGraphResponse alloc] init] autorelease];
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url_string]];

    NSError *err;
    NSURLResponse *resp;
    NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:&resp error:&err];

    if (resp != nil) {

        /**
         * In the case we request a picture (avatar) the Graph API will return to us the actual image
         * bits versus a url to the image.....
         **/
        if ([resp.MIMEType isEqualToString:@"image/jpeg"]) {

            UIImage *image = [UIImage imageWithData:response];
            return_value.imageResponse = image;

        } else {

            NSString *stringResponse = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
            return_value.htmlResponse = stringResponse;
            [stringResponse release];           
        }

    } else if (err != nil) {
        return_value.error = err;
    }

    return return_value;

}

please sugggest me .......

1
  • I suggest you reword your question. While you have provided lots of code, which is great, I personally have no idea what this "access token" is or what you want. Edit the question and please don't start adding comments after mine with ever more confusing modifications of your question.
    – trojanfoe
    Oct 9, 2013 at 5:54

1 Answer 1

0

Looks like the answer to your problem lies within Facebook. Here's a question that should help:

Why is the echo tool saying bad signature?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.