Question

Hi I have create an event on Facebook through my iOS app by following code

-(void) createEvent:(NSString*)eventName Eventdesc:(NSString*)eventdesc EventDate: (NSString*)eventDate{
    NSURL *meurl = [NSURL URLWithString:@"https://graph.facebook.com/me/events"];

    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   eventName, @"name",
                                   eventdesc, @"description",
                                   [NSString stringWithFormat:@"%@",[NSDate date]], @"start_time",
                                   nil];
    SLRequest *merequest = [SLRequest requestForServiceType:SLServiceTypeFacebook
                                              requestMethod:SLRequestMethodPOST
                                                        URL:meurl
                                                 parameters:params];

    merequest.account = _facebookAccount;

    [merequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
        NSString *meDataString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];

        NSLog(@"event %@", meDataString);
        if (!error) {
            UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:@"" message:@"Thanks for your support. Event has been created on your facebook page." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil,nil];
            [alertView show];
        }else{
            UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:@"" message:@"Unable to create event on facebook."  delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil,nil];
            [alertView show];
        }

    }];
}

Now I want to invite friends to this created event. I search lot but I did not get any helpful information. please help. Thank you in advance.

Was it helpful?

Solution

You can invite users to an event by issuing an HTTP POST to /EVENT_ID/invited/USER_ID. You can invite multiple users by issuing an HTTP POST to /EVENT_ID/invited?users=USER_ID1,USER_ID2,USER_ID3. Both of these require the create_event permission and return true if the invite is successful.

OTHER TIPS

Solving the problem by using follwing code

pragma mark- Invite Friends Method

-(void)inviteFriendsToEvent:(NSString*)eventID UserID:(NSMutableArray*)userID{

NSLog(@"ID=%@",[_IDArray lastObject]);
NSLog(@"Event ID:%@",_eventID);


NSData *data = [_eventID dataUsingEncoding:NSUTF8StringEncoding];
id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];

NSLog(@"Event ID:%@",[json objectForKey:@"id"]);

NSURL *meurl = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/invited/%@",[json objectForKey:@"id"],[_IDArray lastObject]]];
//@"https://graph.facebook.com/EVENT_ID/invited?users=USER_ID1,USER_ID2,USER_ID3"
SLRequest *merequest = [SLRequest requestForServiceType:SLServiceTypeFacebook
                                          requestMethod:SLRequestMethodPOST
                                                    URL:meurl
                                             parameters:nil];

merequest.account = _facebookAccount;

[merequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
    NSString *meDataString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
    NSLog(@"Data=%@",meDataString);
}];

}

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