I managed to post a status to my wall with a custom app, but what I want to do, is schedule the status, to be posted on a given datetime.
The problem was, when I close my app, the script is aborted. Right now it works, I'm using ignore_user_abort(true) and sleep().
I'm also using set_time_limit(1), once the given datetime has passed, so the script stops.
I feel like this is crappy coding and want to know if there's a better way to do this?
Here's the code I'm using right now:
<?php
ignore_user_abort(true);
$token=$_GET["access_token"];
$attachment = array(
'access_token' => "$token",
'message' => "deze post moet om 14.14 online komen",
'name' => "testpost",
'link' => "http://myurl.be/",
'description' => "Write here your description",
'picture'=> "http://myurl/assets/images/layout/logo.png");
date_default_timezone_set('Europe/Belgrade');
$time= date('d/m/Y H:i');
if ("10/01/2012 14:14" < $time ){
set_time_limit(1);
$result = $facebook->api('/me/feed/','post',$attachment);
}else{
sleep(60);
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, "https://www.myurl.com/tests/facebooklogin/post.php?access_token=".$token);
curl_exec ($curl);
curl_close ($curl);
}
print $result;
?>