How to use the facebookads.FacebookAdsApi.get_default_api function in facebookads

To help you get started, we’ve selected a few facebookads examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fbsamples / marketing-api-samples / samples / samplecode / instagram_potential.py View on Github external
if story_id == 0:
                comment = 'No post fround in the first creative of this ad set.'
                self.add_check_result(
                    result,
                    {
                        "eligibility": 3,
                    }
                )
                result['preview_url'] = comment
                results.append(result)
                continue

            # Check whether the creative's post is IG ready
            try:
                # This Graph API call is not a part of Ads API thus no SDK
                post = FacebookAdsApi.get_default_api().call(
                    'GET',
                    (story_id,),
                    params={
                        'fields': 'is_instagram_eligible,child_attachments'
                    },
                )
                post_ig_eligible = post.json()['is_instagram_eligible']
            except FacebookRequestError:
                post_ig_eligible = False
            result['creative_ready'] = post_ig_eligible
            if post_ig_eligible:
                self.add_check_result(
                    result,
                    {
                        "eligibility": 5,
                    }
github facebook / facebook-python-business-sdk / examples / docs / fixtures.py View on Github external
def api_get(path, api=None, url=default_api_url):
    if api is None:
        api = FacebookAdsApi.get_default_api()
    response = api.call('GET', url + path)
    return response.json()
github facebook / facebook-python-business-sdk / examples / docs / fixtures.py View on Github external
def api_post(path, params={}, api=None, url=default_api_url, **kwargs):
    if api is None:
        api = FacebookAdsApi.get_default_api()
    response = api.call('POST', url + path, params=params, **kwargs)
    return response.json()