facebook / facebook-ruby-business-sdk

Ruby SDK for Meta Marketing API
https://developers.facebook.com/docs/business-sdk
Other
208 stars 161 forks source link

Filtering doesn't work on FacebookAds::Ad Leads #60

Closed hcancelik closed 5 years ago

hcancelik commented 5 years ago
ad_id = XXXXXX

FacebookAds::Ad.get(ad_id).leads({
    fields:{}, 
    filtering: [{ 
        field:'time_created',
        operator:'GREATER_THAN', 
        value: '2018-12-12T12:00:00-0800'
     }].to_json
}).each(&:inspect)

In my example when I run the code above I get all the leads instead of the ones that are created after 12/12/2018.

No matter what I tried it always returns the all leads. Not sure if I'm doing something wrong or filtering not working.

jingping2015 commented 5 years ago

Did you try call the same Graph API, https://developers.facebook.com/docs/marketing-api/reference/adgroup/leads/ to check if it works ?

hcancelik commented 5 years ago

@jingping2015 it looks like it doesn't work in Graph API either. (though I'm not 100% sure)

I tried time_created, start_time and created_time fields as a parameter but none of them filters the results.

jingping2015 commented 5 years ago

Hey, then I suggest you report the issue on Devsite Bug Report channel: https://developers.facebook.com/support/bugs/, Thanks!

hcancelik commented 5 years ago

@jingping2015 thanks for the response.

It turned out the documentation was incorrect. The filtering was requesting a timestamp instead of date.

filtering=[{"field":"time_created","operator":"GREATER_THAN","value":"1545177600"}]

instead of

filtering=[{"field":"time_created","operator":"GREATER_THAN","value":"2018-12-19T00:00:00"}]

phillipmohr commented 5 months ago

Old thread I know, but does anyone know how we can filter other fields? Such as id (Facebook lead ID) or field_data? I'm getting an unknown error occured when I try to filter these

vkpatil84 commented 2 months ago

I know this is old thread, but recently I'm getting a bug in the Graphs API. While filtering leads in the 'time_created' using date in (UNIX timestamp), it is not actually comparing the leads in seconds. So if the API filtering time - 06-07-2024 11:58:00 AM and the datetime 06-07-2024 11:58:12 AM of leads is the same, and the difference is only in seconds then it still will be present in responses causing duplicates in data.