我正在使用Facebook的营销API来制作广告。我已成功使用单张图片制作广告,但现在我的要求是制作包含多张图片的广告。我不知道如何创建它。
我使用C#在ASP.NET MVC中工作。我试图从facebook上找到c#SDK,但也发现了一个,但其中使用的API太旧了,facebook也没有接受任何API请求。
然后开始关注Facebook指南,使用图API和营销API说明。我在javascript和html5中使用这些链接创建了一个页面,一切正常。但现在却不得不制作包含多张图片的广告。
请有人提出这个想法,我该如何实现呢。我的工作代码是:
=============================================== ==============================
function CarrouselCreative(images, actID, adSetID, campID, callback) {
var apiURL = "/" + actID + "/adcreatives";
var adCreativeName = $("#hdnCreativeName").val() + "-Creative";
var adCreativeTitle = $("#txtCreativeAdTitle").val();
var adCreativeBody = $("#txtAdBodyMessage").val();
var imageURL = "http://www.test.com/wp-content/uploads/2015/04/maplegrove.jpeg";
var url1 = encodeURI("https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTtkBB90ZG2Sk_MaNIvlz9pszpi9JJFnU38ol4Ac-NoDCuX3kGY");
var url2 = encodeURI("https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRrGNQ5PLrhha-T9DAInIw0RtzqfyJUasP1Q-jfrt0nOJ2-qxe6");
var url3 = encodeURI("http://www.test.com");
var object_story = {
"page_id": "18105454546788 ",
"link ": "http: //www.test.com",
"link_data": {
"caption": "My caption",
"child_attachments": [{
"description": "$8.99",
"image_hash": "2423690a56e826ce4af",
"link": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTtkBB90ZG2Sk_MaNIvlz9pszpi9JJFnU38ol4Ac-NoDCuX3kGY",
"name": "Product 1",
"object_type": "PHOTO"
}, {
"description": "$9.99",
"image_hash": "4ff9caa3f714c8096ee",
"link": "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRrGNQ5PLrhha-T9DAInIw0RtzqfyJUasP1Q-jfrt0nOJ2-qxe6",
"name": "Product 2",
"object_type": "PHOTO"
}]
}
}
debugger;
var story = JSON.stringify(object_story);
FB.api(apiURL, 'POST', {
name: adCreativeName,
title: adCreativeTitle,
body: adCreativeBody,
object_story_spec: story
}, function (response) {
if (response.error) {
alert("creativeID: " + response.error.error_user_title + " : " + response.error.error_user_msg);
FB.api(campID, 'DELETE');
}
else {
callback(response.id);
}
});
}
=============================================== =================== 我需要添加与以下错误消息相关的详细信息。 "您的广告必须包含以下功能之一:照片,视频,链接,模板链接,文字或优惠。请添加其中一个资产,然后重试。"
这里我需要做出改变.......
var object_story = {
"page_id": "18105454546788 ",
"link ": "http: //www.test.com",
"link_data": {
"caption": "My caption",
"child_attachments": [{
"description": "$8.99",
"image_hash": "2423690a56e826ce4af",
"link": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTtkBB90ZG2Sk_MaNIvlz9pszpi9JJFnU38ol4Ac-NoDCuX3kGY",
"name": "Product 1",
"object_type": "PHOTO"
}, {
"description": "$9.99",
"image_hash": "4ff9caa3f714c8096ee",
"link": "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRrGNQ5PLrhha-T9DAInIw0RtzqfyJUasP1Q-jfrt0nOJ2-qxe6",
"name": "Product 2",
"object_type": "PHOTO"
}]
}
}
答案 0 :(得分:0)
我在C#代码中使用Python Ads API解决了上述问题。 Facebook提供了制作各种广告的完整指南,包括带有多个图像的carousal广告手段广告。
所以使用Python脚本重新创建完整的代码并在C#中实现。现在我的广告应用程序运行顺利。