I'm trying to send our users notifications via our Facebook app.
Probably to the tune of 50-100 at a time, and can't seem to get the cURL to loop through...I can get one to send, but that's it. Sure I'm just missing something simple, but would love some other sets of eyes on it!
The code is:
<?php
include('../inc.php');
//App Access Token
$appat = file_get_contents("https://graph.facebook.com/oauth/access_token?client_id=xxxxxxxxxx&client_secret=xxxxxxxxxxx&grant_type=client_credentials");
parse_str($appat);
//Notify
$sql = "SELECT * FROM ats";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$userid = $row['UserID'];
$url = "https://graph.facebook.com/$userid/notifications";
$attachment = array(
'access_token' => "$access_token",
'href' => "?a=1",
'template' => "Template Message",
'ref' => "ActT"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
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,1);
$result = curl_exec($ch);
curl_close ($ch);
}
include('../inc2.php');
?>