Images for use in ads can be uploaded and managed independently of ads or creatives.
The image used in an ad group can be specified in the following ways:
Note: The image of sponsored stories is defined by the story being boosted and not by the ad group creative.
| Name | Description | Permission | Returns |
|---|---|---|---|
hash |
The hash which uniquely identifies the image. | ads_management |
string |
url |
A temporary URL which the image can be retrieved at. | ads_management |
string |
To retrieve the available images of an ads account, specify adimages:
act_AccountID/adimages
The images used in every creative in the account should appear in the list of images. Using the image_hash property you can specify the image to be used with new creatives or ad groups.
To retrieve specific images from an ads account specify the hashes of the images in a "hashes" array as follows:
act_AccountID/adimages?hashes=["0d500843a1d4699a0b41e99f4137a5c3","012feg987e98g789f789e87976210983"]
Both of these methods returns an array of adimages as follows:
{
"data": {
"0d500843a1d4699a0b41e99f4137a5c3": {
"hash": "0d500843a1d4699a0b41e99f4137a5c3",
"url": "https://fbcdn-photos-a.akamaihd.net/photos-ak snc1/v41818/flyers/5/36/1314272071984394364_1_88aed216.jpg"
},{
"012feg987e98g789f789e87976210983": {
"hash": "012feg987e98g789f789e87976210983",
"url": "https://fbcdn-photos-a.akamaihd.net/photos-ak snc1/v41818/flyers/5/36/1319872345987987364_1_88443gea.jpg"
}
},
"count": 2,
"limit": 100,
"offset": 0
}
You can upload an image or zip file and use the generated hash to specify the image for use in an ad group or creative. You must include an extension with your filename, e.g. 'sample.jpg' and not just 'sample' or 'sample.tmp', etc.
Zip file.:
curl -F "test.zip=@test.zip" "https://graph.facebook.com/
act_368811234/adimages?access_token=____"
Image file (bmp, jpeg, gif).:
curl -F "test.jpg=@test.jpg" "https://graph.facebook.com/
act_368811234/adimages?access_token=____"
The response is of the following form.:
{"images":{"8cf726a44ab7008c5cc6b4ebd2491234":
{"hash":"8cf726a44ab7008c5cc6b4ebd2491234",
"url":"https:\/\/fbcdn-photos-a.akamaihd.net
\/photos-ak-snc1\/v41818\/flyers\/19\/58\/13117189501439916725_1_3b571234.jpg"}}}
Ad groups and creatives can be created using an image hash as follows.
curl -F "campaign_id=6003417011234" -F "bid_type=1"
-F "max_bid=30" -F "targeting={'countries':['US']}"
-F "creative={'title':'testtitle','body':'test',
'link_url':'http:\/\/www.test.com',
'image_hash':'8cf726a44ab7008c5cc6b4ebd2491234'}"
-F "name=adgroupname"
"https://graph.facebook.com/act_368811234/adgroups?access_token=____"
The response will be similar to the following:
{"id":6003494271234]}
To directly upload an image (instead of using an image hash), add the image file to the multi-part MIME POST and specify the file name.
For example, you could specify the following:
curl -F "campaign_id=6003417011234" -F "bid_type=1"
-F "max_bid=30" -F "targeting={'countries':['US']}"
-F "creative={'title':'test','body':'test',
'link_url':'http:\/\/www.test.com','image_file':'test.jpg'}"
-F "name=test" -F "test.jpg=@.\test.jpg"
"https://graph.facebook.com/act_368811234/adgroups?access_token=___"
The response will be similar to the following:
{"id":6003485421234}
To copy an adimage from one account to another supply the source account and hash of the image in a "copy_from" POST parameter.
curl -F 'access_token=...'
-F 'copy_from=["source_account_id":SourceAccountID, "hash":"02bee5277ec507b6fd0f9b9ff2f22d9c"]'
https://graph.facebook.com/act_DestAccountID/adimages
Note: This copies the adimage from the SourceAccountID and to the DestAccountID account. You must have access to read the creatives from SourceAccountID or you won't be able to copy the images from the account.