views:

79

answers:

3

hello all i want to retrieve my all the wall post that i have posted until now i am using this fql query from my native iphone application in order to fetch it but i think i am maiking some mistake please guide me how could i do that the following is my fql query to get wall post

- (void)session:(FBSession*)session didLogin:(FBUID)uid {

    NSString *fql = [NSString stringWithFormat:@"SELECT comments, likes FROM stream WHERE post_id=100000182297319"];



    NSLog(@"session key is %@",_session.sessionKey);

    NSLog(@"from global key is %@",[twitfacedemoAppDelegate getfacebookkey]);

    NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"];



    [[FBRequest requestWithDelegate:self] call:@"facebook.fql.query" params:params];

this is my other delgate method to get the wall post but this code is not working

- (void)request:(FBRequest*)request didLoad:(id)result {
    @try
    {
        NSLog(@"result is %@",result);

        if(result==nil)
        {
            UIAlertView *a=[[UIAlertView alloc]initWithTitle:@"Can't login" message:@"You cant login here." delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil];
            [a show];
            [a release];
        }
        else
        {
            NSArray* users = result;
            NSDictionary* user = [users objectAtIndex:0];


            NSString* name = [[NSString alloc]initWithString:[user objectForKey:@"name"]];
            NSLog(@"name is %@",name);

            _label.text = [NSString stringWithFormat:@"Logged in as %@", name];

            NSString *globalfacebookname;
            globalfacebookname=[[NSString alloc]initWithString:name];



            NSLog(@"value is %@",globalfacebookname);

            NSString *fid=[user objectForKey:@"uid"];
            NSLog(@"FACEBOOK ID WITH STRING DATATYP %@",fid);
            [twitfacedemoAppDelegate fetchfacebookid:fid];
        }
    }
    @catch (NSException * e) 
    {
        NSLog(@"Problem in dialog didFailWithError:%@",e);
    }

}

please guide me how could i retrieve my all the post from facebook to my native iphone application through fql query

thanks in advance

+2  A: 

cheers i got it i have fired one query after establishing the connection and i got my wall post back to native iphone application here is my query

- (void)session:(FBSession*)session didLogin:(FBUID)uid {
    //_permissionButton.hidden = NO;
    //_feedButton.hidden = NO;
    NSLog(@"DISABLED");
    NSString *fql = [NSString stringWithFormat:@"SELECT actor_id, message FROM stream WHERE source_id = 100000182297319 limit 50"];



    NSLog(@"session key is %@",_session.sessionKey);
    NSLog(@"from global key is %@",[twitfacedemoAppDelegate getfacebookkey]);

    NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"];
    [[FBRequest requestWithDelegate:self] call:@"facebook.fql.query" params:params];
}

and here is the result of it

- (void)request:(FBRequest*)request didLoad:(id)result {
    @try
    {
        NSLog(@"result is %@",result);
        //startride.enabled=FALSE;
        //selectride.enabled=FALSE;
        if(result==nil)
        {
            UIAlertView *a=[[UIAlertView alloc]initWithTitle:@"Can't login" message:@"You cant login here." delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil];
            [a show];
            [a release];
        }
        else
        {
            NSArray* users = result;



            NSDictionary* user = [users objectAtIndex:0];

        }
    }
    @catch (NSException * e) 
    {
        NSLog(@"Problem in dialog didFailWithError:%@",e);
    }

}

at this point you will get all the wall post in to the results dictionary

hardik
+1  A: 

Maybe I'm retarded but I tried this and I always get an empty NSArray back. I am substituting my source_id with my uid obviously with %lld and before I request this I am successfully getting my full name from my profile (so I must be authenticated). This is the exact query I'm using: SELECT actor_id, message FROM stream WHERE source_id = 610611343 limit 50

Do I have to request permissions first or something? Help would be greatly appreciated because I've been going for hours on this and want to pull my hair out. I wish an error code at least would come back - but its always just nothing.

Mike Simmons
Its all a permissions issue. Request for FBPermissionDialog *dialog = [[[FBPermissionDialog alloc] init] autorelease]; dialog.delegate = self; dialog.permission = @"read_stream"; [dialog show];
Mike Simmons