views:

675

answers:

3

Is it possible to use facebook php api and crontab to create status updates? Crontab would run the php code that sends the status update to facebook.

The problem for me is the login part [$facebook->require_login();]. Crontab can't login, so can i send the login information (username and password) to facebook as well?

my example code:

$facebook = new Facebook($api_key, $secret); 
$user = $facebook->require_login(); 

$output = "my status"; 
$result = $facebook->api_client->users_setStatus($output);
+1  A: 

It's possible. A quick google search found this example in perl. Here's another in bash. Also as a side note you should try to make sure your credentials are secured with permissions.

Also take a look at these possible duplicates:

jjclarkson
A: 

You first need to require offline_access and status_update extended permissions.

Once you have the infinite session key stored, you can now use set_user on your cron.

$facebook = new Facebook(API_KEY, API_SECRET);
$facebook->set_user($user_id, $infinit_session);
Alejandro Bologna
A: 

Remove the require_login() because cronjobs will not be able to do so. Make sure you have extended permissions from the application so that the cronjob will be able to update your status.

Steven Lu