Trying to send a scheduled notification to an app user.
The user specify a reminder time that is stored in a MySQL database and using a cron job.
I want to send notification 3 times a day; upon user prefered time (using local time).
I setup the cron to run once every 30 min.
<?php
function runCurl($path)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $path);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$output = curl_exec($ch);
return $output;
curl_close($ch);
}
function getAppUsers()
{
}
function build_batch_request()
{
}
$graph_url = "https://graph.facebook.com/oauth/access_token?client_id=xxx&client_secret=xxx&grant_type=client_credentials&redirect_uri=https://www.example.com/app/";
$result = runCurl($graph_url);
$access_token = json_decode($result)->access_token;
$graph_url = "https://graph.facebook.com/me/notifications?access_token=$access_token&template=Test Message";
$result = runCurl($graph_url);
print_r($result); // for debug only
?>
I am getting error that says that something went wrong from Facebook graph API.
Update: question clarified.
2
Answers
I found my code mistakes:
Here is a tested and working code: I am include the whole cron code; please feel free to edit for optimization and add your input.
Please refer to this answer to learn how to setup a cron task in linux server.
I used this one :
Thanks for all hints; appreciated.
From the link in your question:
You just need an App Access Token: