I am using the Facebook SDK 3.0 on iOS to try to schedule a post to a profile or page. When I try without scheduling, everything goes ok.
However, when I put the following
//scheduleDate is a NSDate between the range 10 minutes - 6 months from now
NSString *timestamp = [NSString stringWithFormat:@"%.0f", [scheduleDate timeIntervalSince1970]];
[requestToPost.parameters setObject:timestamp forKey:@"scheduled_publish_time"];
I receive error 400 and com.facebook.sdk error 5.
Anyone have any idea why it’s not working?
So, it turns out that I needed to be aware of two things here:
1 – As Hemang pointed out, the parameter published must be defined to NO. So, setting something like
[requestToPost.parameters setObject:@"0" forKey:@"published"];or
[requestToPost.parameters setObject:[NSNumber numberWithBool:NO] forKey:@"published"];is mandatory in this case.2 – From my tests and from the docs, scheduling posts only work for Facebook Pages and not for people (profiles).
Also, it’s worth saying again that the date should be between the range 10 minutes – 6 months from ‘now’.