使用Ads API上传image_file [英] Upload image_file using Ads API
问题描述
我正在尝试为活动广告(迁移后)创建新的广告素材,使用字段 image_file
。
I'm trying to create a new Ad Creative for an event ad (Post-Migration), using the field image_file
.
通过 Graph API资源管理器发送以下发布请求:
Via the Graph API Explorer I send the following post request:
网址: https://graph.facebook.com//act_xxxx/adcreatives
object_id:xxxxx
body:body here
title :title here
name:name here
image_file:@C:\Art.jpg
< br>
URL: https://graph.facebook.com//act_xxxx/adcreatives
object_id: xxxxx
body: body here
title: title here
name: name here
image_file: @C:\Art.jpg
我收到以下异常响应:
Adcreative创建失败的原因如下:图像文件无效:image_file字段未指定POST文件名。
"The Adcreative Create Failed for the following reason: Invalid image file: The image_file field does not specify a POST file name."
显然我没有使用image_file参数。我应该如何使用它?
Apparently I'm not using the image_file parameter right. How should I use it?
推荐答案
只尝试上传图片,而不是使用图像哈希来上传广告素材。
Try uploading image only, and than use image hash to upload creative.
参数:
[
IMAGE_NAME => '@' + path
]
POST https://graph.facebook.com//act_xxxx/adimages
IMAGE_NAME的名字带有extension-image.jpg或image.png ...
IMAGE_NAME is name with extension - image.jpg, or image.png...
作为回复,您将获得
[
'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'
这篇关于使用Ads API上传image_file的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!