How to Download Wall Posts from FBConnect iPhone

I am trying to upload user messages on the wall. The FB account with which I receive messages will always be public, so I don’t think you need to log in. I can't find the FBConnect iOS SDK documentation, so I hope someone here can help me.

The latest SDK uses

- (void)requestWithGraphPath:(NSString *)graphPath
               andParams:(NSMutableDictionary *)params
             andDelegate:(id <FBRequestDelegate>)delegate;

to get data from the user's graph. The problem is that I have no idea what acceptable parameters are or what graphPath is. I think the graph path is just a name after www.facebook.com, but I'm not sure.

What I would like to do is get the last 20 wall posts made on the artist’s public page.

Thanks in advance!

Oh, if you know a good place to get the FBConnect iOS documentation, which would be awesome. I know there is a tiny bit on the git hub download page, but I would like to see something more complete.

UPDATE

I found decent documentation. http://developers.facebook.com/docs/reference/api/ I also found that if you just want the page owner to specify / userID / posts rather than / userID / feed.

+3
source share
2 answers
  • The first parameter is really @ "userid / feed"
  • the second one is empty because the feed does not need any parameter, so it [NSDictionary dictionary]will work fine.
  • - , FBRequestDelegate.

:

- (void)request:(FBRequest*)request didLoad:(id)result
- (void)request:(FBRequest*)request didFailWithError:(NSError*)error

: , , , , NSArray .

GraphApi Doc, GraphPath.

+2

FBConnect. a NSURLConnection (, viewDidLoad) Facebook JSON connectionDidFinishLoading:

- (void)viewDidLoad {
    NSURLRequest *request = [NSURLRequest requestWithURL:
                                 [NSURL URLWithString: [NSString stringWithFormat:@"%@%@/feed", @"http://graph.facebook.com/", @"cocacola"]]];
        [NSURLConnection connectionWithRequest:request delegate:self];
}


- (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response {
    [responseData setLength:0];
}

- (void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data {
    [responseData appendData:data];
}

- (void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error {
    NSLog(@"Connection failed: %@", [error description]);
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
    SBJsonParser *parser = [[SBJsonParser alloc] init];
    NSString *json = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
    NSDictionary *dictionary = [parser objectWithString:json];

    NSMutableArray *arr = [dictionary mutableArrayValueForKey:@"data"];
    int len = [arr count];
    for(int i = 0; i < len; ++i) {
        NSDictionary *d = [arr objectAtIndex:i];
        [list addObject:d];
    }
    [json release];
    [parser release];
}

list NSMutableArray, SBJsonParser (json-framework objective-c, . http://json.org), responseData NSMutableData

, list :

NSString *message= [[list objectAtIndex:0] objectForKey:@"message"];

, :

self.profileImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@/picture", @"http://graph.facebook.com/", @"cocacola"]]]];

profileImage - UIImage.

@"cocacola"

0

Source: https://habr.com/ru/post/1778541/


All Articles