Last active
August 29, 2015 13:57
-
-
Save yyoshiki41/9442903 to your computer and use it in GitHub Desktop.
Facebook notifications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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