-4

I need to create simple php application to check friends who have birthday today and tag them saying happy birthday.

At least I need to if it's possible or not?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Chathura
  • 155
  • 6

2 Answers2

2

Login using CURL: Not possible without user interaction. Check out the Facebook docs for information about Login possibilities: https://developers.facebook.com/docs/facebook-login/v2.1

Post on the user wall: https://developers.facebook.com/docs/graph-api/reference/v2.1/user/feed/

You need to authorize a user with the publish_actions permission for that. The better (and less spammy) way would be the Share Dialog though: https://developers.facebook.com/docs/sharing/reference/share-dialog

That being said, your idea of getting the birthdays of your friends and tagging them to say "Happy Birthday", i am afraid it´s not possible for several reasons:

  • friend permissions are deprecated, you can´t get any data from friends anymore. See changelog for more information: https://developers.facebook.com/docs/apps/changelog
  • Auto-posting on a Facebook Wall is considered spam, you would not get publish_actions approved for auto-posting birthday wishes. Also see changelog for more information about permission approval.
  • The message parameter always has to be 100% user generated, so you can´t just generate a message. See the policy for more information about that: https://developers.facebook.com/policy/
  • User Access Tokens are only valid for 2 hours, or 60 days if you extend and save them. After those 60 days, the user would have to refresh the token by visiting the App again.
andyrandy
  • 72,880
  • 8
  • 113
  • 130
0

See here: Post to a Facebook user's wall with cURL PHP

Code from that topic just in-case it gets removed:

$attachment =  array(
'access_token' => $token,
'message' => $msg,
'name' => $title,
'link' => $uri,
'description' => $desc,
'picture'=>$pic,
'actions' => json_encode(array('name' => $action_name,'link' => $action_link))
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://graph.facebook.com/fbnameorid/feed');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  //to suppress the curl output 
$result = curl_exec($ch);
curl_close ($ch);

Good luck!

Community
  • 1
  • 1
Brandon Palmer
  • 313
  • 2
  • 11