How to use the facebookads.test_config 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 facebook / facebook-python-business-sdk / examples / docs / adgroup.py View on Github external
# shall be included in all copies or substantial portions of the software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

from facebookads import test_config
from facebookads.objects import AdLabel
from examples.docs import fixtures
import string

ad_account_id = test_config.account_id
app_id = test_config.app_id
page_id = test_config.page_id
ad_set_id = fixtures.create_adset().get_id_assured()
ad_group_id = fixtures.create_adgroup().get_id_assured()
creative_id = fixtures.create_creative().get_id_assured()
image_hash = fixtures.create_image().get_hash()


# _DOC open [ADGROUP_CREATE]
# _DOC vars [ad_account_id:s, ad_set_id, creative_id]
from facebookads.objects import AdGroup

adgroup = AdGroup(parent_id=ad_account_id)
adgroup[AdGroup.Field.name] = 'My AdGroup'
adgroup[AdGroup.Field.campaign_id] = ad_set_id
adgroup[AdGroup.Field.status] = AdGroup.Status.paused
github facebook / facebook-python-business-sdk / examples / docs / adcreative.py View on Github external
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

from facebookads.objects import AdImage
from facebookads.objects import AdPreview
from facebookads import test_config
from examples.docs import fixtures

ad_account_id = test_config.account_id
page_id = test_config.page_id
product_catalog_id = test_config.product_catalog_id
product_set_id = test_config.product_set_id

image_hash = fixtures.create_image().get_hash()
link = 'http://example.com'


# _DOC open [ADCREATIVE_CREATE_LINK_AD]
# _DOC vars [ad_account_id:s, image_hash:s, page_id, link:s]
from facebookads.objects import AdCreative
from facebookads.specs import ObjectStorySpec, LinkData

link_data = LinkData()
link_data[LinkData.Field.message] = 'try it out'
link_data[LinkData.Field.link] = link
link_data[LinkData.Field.caption] = 'My caption'
link_data[LinkData.Field.image_hash] = image_hash
github facebook / facebook-python-business-sdk / examples / docs / PRODUCTCATALOG_REMOVE_EXTERNAL_EVENT_SOURCES.py View on Github external
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

from facebookads import test_config
from examples.docs import fixtures
from facebookads.objects import ProductCatalog

product_catalog_id = fixtures.create_product_catalog().get_id()
pixel_id = fixtures.create_ads_pixel().get_id()
app_id = test_config.app_id

product_catalog = ProductCatalog(product_catalog_id)
product_catalog.add_external_event_sources([
    pixel_id,
    app_id,
])

# _DOC oncall [pruno]
# _DOC open [PRODUCTCATALOG_REMOVE_EXTERNAL_EVENT_SOURCES]
# _DOC vars [product_catalog_id, pixel_id, app_id]
from facebookads.objects import ProductCatalog

product_catalog = ProductCatalog(product_catalog_id)
product_catalog.remove_external_event_sources([
    pixel_id,
    app_id,
github facebook / facebook-python-business-sdk / examples / docs / fixtures.py View on Github external
def get_page_access_token():
    data = api_get('/me/accounts')['data']
    for page in data:
        if page['id'] == str(test_config.page_id):
            return page['access_token']
    raise 'Page access token for page id {} not found.'.\
        format(test_config.page_id)
github facebook / facebook-python-business-sdk / examples / docs / adcreative.py View on Github external
# shall be included in all copies or substantial portions of the software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

from facebookads.objects import AdImage
from facebookads.objects import AdPreview
from facebookads import test_config
from examples.docs import fixtures

ad_account_id = test_config.account_id
page_id = test_config.page_id
product_catalog_id = test_config.product_catalog_id
product_set_id = test_config.product_set_id

image_hash = fixtures.create_image().get_hash()
link = 'http://example.com'


# _DOC open [ADCREATIVE_CREATE_LINK_AD]
# _DOC vars [ad_account_id:s, image_hash:s, page_id, link:s]
from facebookads.objects import AdCreative
from facebookads.specs import ObjectStorySpec, LinkData

link_data = LinkData()
link_data[LinkData.Field.message] = 'try it out'
link_data[LinkData.Field.link] = link
github facebook / facebook-python-business-sdk / examples / docs / fixtures.py View on Github external
def get_page_api():
    page_token = get_page_access_token()
    session = FacebookSession(test_config.app_id,
                              test_config.app_secret,
                              page_token)
    return FacebookAdsApi(session)