Python - How to filter on Facebook Marketing API AdAccount.get_lead_gen_forms?












2















How can i define a filter for Facebook Marketing API for the method get_lead_gen_forms? I have tried passing some params, but nothing works.



I need to filter by date because the number of data is exceeding my limit.
Here's my code (* the code already works, need help with the filter):



from facebook_business.api import FacebookAdsApi
from facebook_business.adobjects.adaccount import AdAccount

FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token)
account = AdAccount('act_accountid')
leadgenforms = account.get_lead_gen_forms()


And here is the params that i have tried:



# attempt 1
params = {
'time_range': {
'since': date_start,
'until': date_end
}
}
leadgenforms = account.get_lead_gen_forms(params=params)

# attempt 2
params = {
'filtering': [{
'field': 'created_time',
'operator': 'GREATER_THAN',
'value': date_start }]
}
leadgenforms = account.get_lead_gen_forms(params=params)









share|improve this question





























    2















    How can i define a filter for Facebook Marketing API for the method get_lead_gen_forms? I have tried passing some params, but nothing works.



    I need to filter by date because the number of data is exceeding my limit.
    Here's my code (* the code already works, need help with the filter):



    from facebook_business.api import FacebookAdsApi
    from facebook_business.adobjects.adaccount import AdAccount

    FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token)
    account = AdAccount('act_accountid')
    leadgenforms = account.get_lead_gen_forms()


    And here is the params that i have tried:



    # attempt 1
    params = {
    'time_range': {
    'since': date_start,
    'until': date_end
    }
    }
    leadgenforms = account.get_lead_gen_forms(params=params)

    # attempt 2
    params = {
    'filtering': [{
    'field': 'created_time',
    'operator': 'GREATER_THAN',
    'value': date_start }]
    }
    leadgenforms = account.get_lead_gen_forms(params=params)









    share|improve this question



























      2












      2








      2








      How can i define a filter for Facebook Marketing API for the method get_lead_gen_forms? I have tried passing some params, but nothing works.



      I need to filter by date because the number of data is exceeding my limit.
      Here's my code (* the code already works, need help with the filter):



      from facebook_business.api import FacebookAdsApi
      from facebook_business.adobjects.adaccount import AdAccount

      FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token)
      account = AdAccount('act_accountid')
      leadgenforms = account.get_lead_gen_forms()


      And here is the params that i have tried:



      # attempt 1
      params = {
      'time_range': {
      'since': date_start,
      'until': date_end
      }
      }
      leadgenforms = account.get_lead_gen_forms(params=params)

      # attempt 2
      params = {
      'filtering': [{
      'field': 'created_time',
      'operator': 'GREATER_THAN',
      'value': date_start }]
      }
      leadgenforms = account.get_lead_gen_forms(params=params)









      share|improve this question
















      How can i define a filter for Facebook Marketing API for the method get_lead_gen_forms? I have tried passing some params, but nothing works.



      I need to filter by date because the number of data is exceeding my limit.
      Here's my code (* the code already works, need help with the filter):



      from facebook_business.api import FacebookAdsApi
      from facebook_business.adobjects.adaccount import AdAccount

      FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token)
      account = AdAccount('act_accountid')
      leadgenforms = account.get_lead_gen_forms()


      And here is the params that i have tried:



      # attempt 1
      params = {
      'time_range': {
      'since': date_start,
      'until': date_end
      }
      }
      leadgenforms = account.get_lead_gen_forms(params=params)

      # attempt 2
      params = {
      'filtering': [{
      'field': 'created_time',
      'operator': 'GREATER_THAN',
      'value': date_start }]
      }
      leadgenforms = account.get_lead_gen_forms(params=params)






      python facebook-graph-api facebook-ads-api facebook-marketing-api facebook-python-business-sdk






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 15 '18 at 8:50









      Matteo

      26.6k105977




      26.6k105977










      asked Nov 6 '18 at 20:14









      Kauann H. de OliveiraKauann H. de Oliveira

      261




      261
























          1 Answer
          1






          active

          oldest

          votes


















          0














          You should filter for the field time_created instead of created_time.



          From the section Filtering Leads of the doc here:




          This example filters leads based on timestamps. Timestamps should be
          Unix timestamp.



          curl -G 
          --data-urlencode 'filtering=[
          {
          "field": "time_created",
          "operator": "GREATER_THAN",
          "value": 1516682744
          }
          ]'
          -d 'access_token=<ACCESS_TOKEN>'
          https://graph.facebook.com/v2.11/<AD_ID>/leads



          So, in the second attempt example:



          # attempt 2
          params = {
          'filtering': [{
          'field': 'time_created',
          'operator': 'GREATER_THAN',
          'value': date_start }]
          }
          leadgenforms = account.get_lead_gen_forms(params=params)


          you should use, ad date_start, a date in format of the unix timestamp:




          number of seconds since the Unix Epoch




          Hope this help






          share|improve this answer


























          • Didn't work, it's still not filtering.

            – Kauann H. de Oliveira
            Nov 14 '18 at 19:29











          • Hi @KauannH.deOliveira You should filter for the field time_created instead of created_time. See my update

            – Matteo
            Nov 15 '18 at 8:58











          • The problem continues, i have checked the source code of python sdk here and i saw that method get_lead_gen_forms only accept the field query for params.

            – Kauann H. de Oliveira
            Nov 20 '18 at 19:50











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53179340%2fpython-how-to-filter-on-facebook-marketing-api-adaccount-get-lead-gen-forms%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You should filter for the field time_created instead of created_time.



          From the section Filtering Leads of the doc here:




          This example filters leads based on timestamps. Timestamps should be
          Unix timestamp.



          curl -G 
          --data-urlencode 'filtering=[
          {
          "field": "time_created",
          "operator": "GREATER_THAN",
          "value": 1516682744
          }
          ]'
          -d 'access_token=<ACCESS_TOKEN>'
          https://graph.facebook.com/v2.11/<AD_ID>/leads



          So, in the second attempt example:



          # attempt 2
          params = {
          'filtering': [{
          'field': 'time_created',
          'operator': 'GREATER_THAN',
          'value': date_start }]
          }
          leadgenforms = account.get_lead_gen_forms(params=params)


          you should use, ad date_start, a date in format of the unix timestamp:




          number of seconds since the Unix Epoch




          Hope this help






          share|improve this answer


























          • Didn't work, it's still not filtering.

            – Kauann H. de Oliveira
            Nov 14 '18 at 19:29











          • Hi @KauannH.deOliveira You should filter for the field time_created instead of created_time. See my update

            – Matteo
            Nov 15 '18 at 8:58











          • The problem continues, i have checked the source code of python sdk here and i saw that method get_lead_gen_forms only accept the field query for params.

            – Kauann H. de Oliveira
            Nov 20 '18 at 19:50
















          0














          You should filter for the field time_created instead of created_time.



          From the section Filtering Leads of the doc here:




          This example filters leads based on timestamps. Timestamps should be
          Unix timestamp.



          curl -G 
          --data-urlencode 'filtering=[
          {
          "field": "time_created",
          "operator": "GREATER_THAN",
          "value": 1516682744
          }
          ]'
          -d 'access_token=<ACCESS_TOKEN>'
          https://graph.facebook.com/v2.11/<AD_ID>/leads



          So, in the second attempt example:



          # attempt 2
          params = {
          'filtering': [{
          'field': 'time_created',
          'operator': 'GREATER_THAN',
          'value': date_start }]
          }
          leadgenforms = account.get_lead_gen_forms(params=params)


          you should use, ad date_start, a date in format of the unix timestamp:




          number of seconds since the Unix Epoch




          Hope this help






          share|improve this answer


























          • Didn't work, it's still not filtering.

            – Kauann H. de Oliveira
            Nov 14 '18 at 19:29











          • Hi @KauannH.deOliveira You should filter for the field time_created instead of created_time. See my update

            – Matteo
            Nov 15 '18 at 8:58











          • The problem continues, i have checked the source code of python sdk here and i saw that method get_lead_gen_forms only accept the field query for params.

            – Kauann H. de Oliveira
            Nov 20 '18 at 19:50














          0












          0








          0







          You should filter for the field time_created instead of created_time.



          From the section Filtering Leads of the doc here:




          This example filters leads based on timestamps. Timestamps should be
          Unix timestamp.



          curl -G 
          --data-urlencode 'filtering=[
          {
          "field": "time_created",
          "operator": "GREATER_THAN",
          "value": 1516682744
          }
          ]'
          -d 'access_token=<ACCESS_TOKEN>'
          https://graph.facebook.com/v2.11/<AD_ID>/leads



          So, in the second attempt example:



          # attempt 2
          params = {
          'filtering': [{
          'field': 'time_created',
          'operator': 'GREATER_THAN',
          'value': date_start }]
          }
          leadgenforms = account.get_lead_gen_forms(params=params)


          you should use, ad date_start, a date in format of the unix timestamp:




          number of seconds since the Unix Epoch




          Hope this help






          share|improve this answer















          You should filter for the field time_created instead of created_time.



          From the section Filtering Leads of the doc here:




          This example filters leads based on timestamps. Timestamps should be
          Unix timestamp.



          curl -G 
          --data-urlencode 'filtering=[
          {
          "field": "time_created",
          "operator": "GREATER_THAN",
          "value": 1516682744
          }
          ]'
          -d 'access_token=<ACCESS_TOKEN>'
          https://graph.facebook.com/v2.11/<AD_ID>/leads



          So, in the second attempt example:



          # attempt 2
          params = {
          'filtering': [{
          'field': 'time_created',
          'operator': 'GREATER_THAN',
          'value': date_start }]
          }
          leadgenforms = account.get_lead_gen_forms(params=params)


          you should use, ad date_start, a date in format of the unix timestamp:




          number of seconds since the Unix Epoch




          Hope this help







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 15 '18 at 8:57

























          answered Nov 13 '18 at 13:38









          MatteoMatteo

          26.6k105977




          26.6k105977













          • Didn't work, it's still not filtering.

            – Kauann H. de Oliveira
            Nov 14 '18 at 19:29











          • Hi @KauannH.deOliveira You should filter for the field time_created instead of created_time. See my update

            – Matteo
            Nov 15 '18 at 8:58











          • The problem continues, i have checked the source code of python sdk here and i saw that method get_lead_gen_forms only accept the field query for params.

            – Kauann H. de Oliveira
            Nov 20 '18 at 19:50



















          • Didn't work, it's still not filtering.

            – Kauann H. de Oliveira
            Nov 14 '18 at 19:29











          • Hi @KauannH.deOliveira You should filter for the field time_created instead of created_time. See my update

            – Matteo
            Nov 15 '18 at 8:58











          • The problem continues, i have checked the source code of python sdk here and i saw that method get_lead_gen_forms only accept the field query for params.

            – Kauann H. de Oliveira
            Nov 20 '18 at 19:50

















          Didn't work, it's still not filtering.

          – Kauann H. de Oliveira
          Nov 14 '18 at 19:29





          Didn't work, it's still not filtering.

          – Kauann H. de Oliveira
          Nov 14 '18 at 19:29













          Hi @KauannH.deOliveira You should filter for the field time_created instead of created_time. See my update

          – Matteo
          Nov 15 '18 at 8:58





          Hi @KauannH.deOliveira You should filter for the field time_created instead of created_time. See my update

          – Matteo
          Nov 15 '18 at 8:58













          The problem continues, i have checked the source code of python sdk here and i saw that method get_lead_gen_forms only accept the field query for params.

          – Kauann H. de Oliveira
          Nov 20 '18 at 19:50





          The problem continues, i have checked the source code of python sdk here and i saw that method get_lead_gen_forms only accept the field query for params.

          – Kauann H. de Oliveira
          Nov 20 '18 at 19:50




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53179340%2fpython-how-to-filter-on-facebook-marketing-api-adaccount-get-lead-gen-forms%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          List item for chat from Array inside array React Native

          Thiostrepton

          Caerphilly