Facebook status update with PHP and Cron
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 Faceboo开发者_如何学Gok($api_key, $secret);
$user = $facebook->require_login();
$output = "my status";
$result = $facebook->api_client->users_setStatus($output);
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:
- question 1
- question 2
- question 3
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);
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.
精彩评论