Upload image_file using Ads API

后端 未结 1 1408
名媛妹妹
名媛妹妹 2021-01-20 00:29

I\'m trying to create a new Ad Creative for an event ad (Post-Migration), using the field image_file.

Via the Graph API Explore

相关标签:
1条回答
  • 2021-01-20 01:29

    Try uploading image only, and than use image hash to upload creative.

    Parameters:

    [
     IMAGE_NAME => '@' + path
    ]
    
    POST https://graph.facebook.com//act_xxxx/adimages 
    

    IMAGE_NAME is name with extension - image.jpg, or image.png...

    As the response, you will get

    [
     'images' => [
        [
          'hash' => ...,
          'url' => ....
        ]
      ]
    ]
    

    Than use the image hash you received and create ad creative with that.

    If you want to do only one request, do next:

    curl \
    -F 'access_token=...' \
    -F 'title=Test title' \
    -F 'body=Test body' \
    -F 'link_url=http://www.whatever.com' \
    -F 'name=test creative' \
    -F 'image_file=Art.jpg' \
    -F 'Art.jpg=@C:\Art.jpg ' \
    'https://graph.facebook.com/act_xxxx/adcreatives'
    
    0 讨论(0)
提交回复
热议问题