Skip to content

Instantly share code, notes, and snippets.

@yyoshiki41
Last active August 29, 2015 13:57
Show Gist options
  • Save yyoshiki41/9442903 to your computer and use it in GitHub Desktop.
Save yyoshiki41/9442903 to your computer and use it in GitHub Desktop.
Facebook notifications
$accessToken = $app_Id.'|'.$app_accessToken;
$url = "https://graph.facebook.com/{$facebookId}/notifications"; // API URL
$linkUrl = "index.php"; // app内の相対URL
$notificationTemplate = "Test";
// POST params
$params = "access_token={$accessToken}";
$params .= "&href={$linkUrl}";
$params .= "&template={$notificationTemplate}";
// curl
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$res = curl_exec($ch);
if ($res === false) {
echo 'Curl error: ' . curl_error($ch);
} else {
echo 'Operation completed without any errors';
}
curl_close($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment