Reputation: 512
I am trying to retrieve leads of Facebook page forms from Facebook Marketing API using curl in PHP:
$ch = curl_init();
$user_link = https://graph.facebook.com/v2.7/'.$formDetails[0].'/leads?access_token='.$page->page_access_token;
curl_setopt($ch, CURLOPT_URL, $user_link);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$temp_output = curl_exec($ch);
I am getting leads from this curl hit, Now the problem is I want to retrieve based on timestamp as specified in https://developers.facebook.com/docs/marketing-api/guides/lead-ads/leads/v2.8 this is my code for retrieving leads based on timestamp
$data = [array(
"field" => "time_created",
"operator" => "GREATER_THAN",
"value" => 1476275295
)];
$data = json_encode($data);
$ch = curl_init();
$user_link = "https://graph.facebook.com/2.7/<form_id>/leads?filtering=".$data."&access_token=my access token";
curl_setopt($ch, CURLOPT_URL, $user_link);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$temp_output = curl_exec($ch);
$output = json_decode($temp_output);
I am getting error as
{
"error": {
"message": "Unknown path components: /my form_id/leads",
"type": "OAuthException",
"code": 2500,
"fbtrace_id": "CP5hFV3v1zN"
}
}
Upvotes: 0
Views: 2397
Reputation: 71
When retrieving the leads using either /leads of leads, you get the created date time timestamp which looks like "created_time": "2017-03-08T23:15:14+0000"
If you use the UNIX timestamp value for for the above in the filtering parameter the api will only return those leads which were generated post the specified time.
Upvotes: 1