Skip to content

Instantly share code, notes, and snippets.

@clemfromspace
Last active July 8, 2022 12:54
Show Gist options
  • Save clemfromspace/35175d98aeaf246d99a92998f0ab7c54 to your computer and use it in GitHub Desktop.
Save clemfromspace/35175d98aeaf246d99a92998f0ab7c54 to your computer and use it in GitHub Desktop.
Instagram and Facebook ads with Algolia Recommend
import requests
facebook_api_version = 'v14.0'
facebook_catalog_id = '<facebook-catalog-id>'
facebook_api_token = '<facebook-api-token>'
res = requests.post(
f'https://graph.facebook.com/{api_version}/{product_catalog_id}/product_sets',
json={
'access_token': facebook_api_token,
'name': 'Trending products',
'filter': {
'retailer_id': {
'is_any': trending_product_skus
}
}
}
)
trending_product_set_id = res.json()['id']
import requests
facebook_api_version = 'v14.0'
facebook_api_token = '<facebook-api-token>'
# The `product_set_id` is obtained during the creation of the product set, refer to the `create_product_set.py` file.
facebook_product_set_id = ''
# Refer to the `fetch_trending_product_skus.py` file for fetching the trending products.
trending_products = []
requests.post(
f'https://graph.facebook.com/{version}/{product_set_id}/',
json={
'access_token': facebook_api_token,
'filter': {
"retailer_id": {
"is_any": [product['sku'] for product in trending_products]
}
}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment