4

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);
koppa
  • 41
  • 1
  • 2
  • As soon as you're in PHP, you can do anything you can do in PHP. So, you login however the Facebook API tells you to login in PHP. – Dominic Rodger Dec 18 '09 at 13:51
  • Actually Dominic, this question has more to do with the Facebook platform than with PHP, and you cannot use the API to remotely log in to Facebook. If your FB app has the correct extended permissions, this is possible without a session key. For any other user, the app would need a current valid session key for the given user as passed to it by Facebook. The user would have to be logged in to Facebook and then authorize the application, at which point FB will pass the app a session key. – defines Dec 18 '09 at 15:44
  • Dustin, what extended permissions should i use? offline_access and status_update? – koppa Dec 18 '09 at 16:30

3 Answers3

2

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:

Community
  • 1
  • 1
jjclarkson
  • 5,890
  • 6
  • 40
  • 62
1

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);
0

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
  • 2,150
  • 1
  • 24
  • 33