0

I ask because the examples in the Facebook Ads API (https://developers.facebook.com/docs/reference/ads-api/adimage/#create) for creating an Ad Image all use curl, but I want to do it with python requests. Or if someone can answer the more specific question of how to create an Ad Image on the Facebook Ads API from python, that'd be great as well. You can assume I have the location on disk of the image file to upload. Should be a simple POST request to the endpoint /act_[account_id]/adimages, right?

tscizzle
  • 11,191
  • 15
  • 54
  • 88

3 Answers3

0

I would use something like this:

Or you might want to check out this answer:

Personally, I would think you could use a mixture of Facebook Python SDK and requests

Community
  • 1
  • 1
Mike Driscoll
  • 32,629
  • 8
  • 45
  • 88
  • The first two links are the same link, so I assume the second one was supposed to be something different? – tscizzle Jun 30 '14 at 20:41
  • Also, the facebook-ads-api has nothing about creating Ad Images, as far as I can tell. Doing a 'find' on "image" only yields the "get_adimages()" method. – tscizzle Jun 30 '14 at 20:56
  • yeah...something happened to my link. Fixed it. That's too bad about the first link not doing image ads. The docs weren't very helpful. – Mike Driscoll Jun 30 '14 at 21:00
0

I've written a Python client for Facebook Ads API, it's very simple to use: https://github.com/rpedigoni/fbads

You can make ad creatives without uploading the images, using its URL directly, see this example:

fbads = FBAds(account_id='1378857852381224', access_token='a_valid_token')
creative_id = fbads.creative.add(
    title=u'Test creative',
    body=u'Testing creative creation! Lorem ipsum here.',
    link_url='http://fbads.readthedocs.org/en/latest/index.html',
    image_url='https://d1dhh18vvfes41.cloudfront.net/417x300/051057500.jpg',
)

https://github.com/rpedigoni/fbads/blob/master/tests/test_creative.py#L8

renatogp
  • 75
  • 7
0

Apologies if this is too late, but just in case it isn't, you can use the official Facebook Python Ads API SDK.

You can create an Ad Image using this code (from docs):

from facebookads.objects import AdImage

image = AdImage(parent_id='act_<AD_ACCOUNT_ID>')
image[AdImage.Field.filename] = './test.jpg'
image.remote_create()

# Image Hash
print image[AdImage.Field.hash]
Evan Chen
  • 106
  • 2