facebook api之Marketing API
General information on the Marketing APIs, access, versioning and more. The main use cases for the Marketing API are ads insights, audience management, and ads management:
- Ads Insights and Insights API Reference
- Audience Management: manage your first party data, find new customers, and reengage existing customers through Custom Audience targeting on Facebook. Getting started on the Audience Management API and Custom Audiences Reference
- Ads Management API: The full suite of APIs, from ad creation and management, reporting, and audience management. Getting started on the Ads Management API and Ads Management API Guides
Learn the basic structure and usage of the Marketing API.
- Access and Authentication - Marketing API has three levels of access: development, basic, and standard access levels. Each level of access has certain restrictions, described in this article. Set up your dev environment and obtain an access token.
- Testing - Learn how to test the Marketing API.
- Graph API - REST-based foundation for Marketing API, how to make all CRUD operations, error handling, and debugging tips.
- Object Structure - Campaigns, ad sets, ads and ad creatives.
Versioning
Learn more about upcoming changes and deprecations using our versioning and migration systems.
- Versioning Overview - Facebook's Marketing API supports versioning cycles for app development stability. Learn more here.
- Migrations - Future and past Facebook Platform Migrations. Migrations are used to apply changes across all existing versions.
- Changelog - This changelog covers what's changed in Facebook's Marketing API. These changes include Facebook's server-side APIs and SDKs.
- Upgrade Guide - Details about the individual changes in each version and helps you upgrade your apps across versions.
Ads Management
Create ad campaigns, provide bids for ads auction, and manage ad creative.
Quickstart
Here are the basics steps to manage ad campaigns with the Facebook Marketing API.
1. Create a Campaign
2. Define Targeting
3. Define Budget, Billing, Optimization, and Duration
4. Create Ad Creative
5. Book Ad
#Create a Campaign
curl \
-F 'name=My campaign' \
-F 'objective=LINK_CLICKS' \
-F 'status=PAUSED' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/campaigns #Define Targeting
curl -G \
-d 'type=adinterest' \
-d 'q=baseball' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/search #Define Budget, Billing, Optimization, and Duration
curl \
-F 'name=My Ad Set' \
-F 'optimization_goal=REACH' \
-F 'billing_event=IMPRESSIONS' \
-F 'bid_amount=2' \
-F 'daily_budget=1000' \
-F 'campaign_id=<CAMPAIGN_ID>' \
-F 'targeting={"geo_locations":{"countries":["US"]}}' \
-F 'start_time=2018-02-06T04:45:17+0000' \
-F 'end_time=2018-02-13T04:45:17+0000' \
-F 'status=PAUSED' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/adsets #Provide Ad Creative #First, create an AdImage from an image file.
curl \
-F 'filename=@<IMAGE_PATH>' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/adimages #Then, use the image hash to create the AdCreative.
curl \
-F 'name=Sample Creative' \
-F 'object_story_spec={
"link_data": {
"image_hash": "<IMAGE_HASH>",
"link": "<URL>",
"message": "try it out"
},
"page_id": "<PAGE_ID>"
}' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/adcreatives #The AdCreative with your link is not yet visible in Ads Manager. You see this data once you book you ad. You can debug your ad creative with Graph API Explorer:
#GET /{my-creative-id} HTTP/1.1
#Host: graph.facebook.com #Schedule Delivery
curl \
-F 'name=My Ad' \
-F 'adset_id=<AD_SET_ID>' \
-F 'creative={"creative_id":"<CREATIVE_ID>"}' \
-F 'status=PAUSED' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/ads
Campaign Structure
Facebook's campaign structure has 3 levels: campaign, ad set and ad. In the API, there is a fourth level available for developers, called the creative.

Campaigns contains your advertising objective and one or more ad sets. This helps you optimize and measure results for each advertising objective.
Ad Sets have one or more ads. You define budget and schedule for each ad set. Create an ad set for each target audience with your bid; ads in the set target the same audience with the same bid. This helps control the amount you spend on each audience, determine when audience will see your ads, and provides metrics for each audience.
Ads contain ad creative). Create multiple ads in each ad set will to optimize ad delivery based different images, links, video, text or placements.
Ad creatives contain just the visual elements of the ad and once created, are immutable. Each ad account has a creative library to store creatives for reuse in ads.
| Objective | Schedule | Budget | Bidding | Targeting | Creative | |
|---|---|---|---|---|---|---|
|
Campaign |
✓ |
|||||
|
Ad Set |
✓ |
✓ |
✓ |
✓ |
||
|
Ad |
✓ |
Mapping between the public facing naming of the object and API endpoints:
| Public facing name | API endpoint |
|---|---|
|
Campaign |
/campaigns |
|
Ad Set |
/adsets |
|
Ad |
/ads |
|
Creative |
/adcreatives |
#To read the campaigns associated with a specific account
curl -G \
-d 'effective_status=["ACTIVE","PAUSED"]' \
-d 'fields=name,objective' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/campaigns #We also show some high level insights, including impressions, clicks and the amount spent. You can retrieve these by calling the following endpoint, optionally specifying the start and/or end time:
curl -G \
-d 'end_time=1517287567' \
-d 'fields=impressions,inline_link_clicks,spend' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/<CAMPAIGN_ID>/insights #Ad sets are groups of ads, and are used to configure the budget and period the ads should run for. All ads contained within an ad set should have the same targeting.
curl \
-F 'name=My First AdSet' \
-F 'lifetime_budget=20000' \
-F 'start_time=<START_TIME>' \
-F 'end_time=<END_TIME>' \
-F 'campaign_id=<CAMPAIGN_ID>' \
-F 'bid_amount=500' \
-F 'billing_event=IMPRESSIONS' \
-F 'optimization_goal=POST_ENGAGEMENT' \
-F 'targeting={
"age_max": 24,
"age_min": 20,
"behaviors": [{"id":6002714895372,"name":"All travelers"}],
"genders": [1],
"geo_locations": {
"countries": ["JP"],
"regions": [{"key":"3886"}],
"cities": [
{
"key": "2420605",
"radius": 10,
"distance_unit": "mile"
}
]
},
"home_ownership": [{"id":6006371327132,"name":"Renters"}],
"interests": [{"id":6003107902433,"name":"Association football (Soccer)"}],
"life_events": [{"id":6002714398172,"name":"Newlywed (1 year)"}],
"publisher_platforms": ["facebook","audience_network"]
}' \
-F 'status=PAUSED' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/adsets # list all ad sets within a campaign.
curl -G \
-d 'fields=name,start_time,end_time,daily_budget,lifetime_budget' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/<CAMPAIGN_ID>/adsets #Ads:An ad object contains all of the information neccessary to display an ad on Facebook, such as the creative.
curl \
-F 'name=My Ad' \
-F 'adset_id=<AD_SET_ID>' \
-F 'creative={"creative_id":"<CREATIVE_ID>"}' \
-F 'status=PAUSED' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/ads # list all of the ads for an ad set within your UI.
curl -G \
--data-urlencode 'effective_status=[
"ACTIVE",
"PAUSED",
"PENDING_REVIEW",
"PREAPPROVED"
]' \
-d 'fields=name,configured_status,effective_status,creative' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/<AD_SET_ID>/ads
Objectives
Objectives are actions you want people to make when they see the ad and objects are what people act upon. See Help Center.
#Setting Objectives:After you create new campaign, ad set, ad, and ad creative objects, provide the required fields for each object creation. #The minimum API call needed to create a campaign: curl \
-F 'name=My First Campaign' \
-F 'objective=<OBJECTIVE>' \
-F 'status=PAUSED' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/campaigns #Explicitly setting the objective has the following benefits:
#You get correct tracking, optimization, and bidding options for your ad.
#You can view unique UI and analytics dashboards for each objective
#See campaign for acceptable values for the objective parameter. For this example, let's choose POST_ENGAGEMENT:
curl \
-F 'name=My First Campaign' \
-F 'objective=POST_ENGAGEMENT' \
-F 'status=PAUSED' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/campaigns
Reference
- Ad Units
- Dynamic Ads - Ads based on your product catalog.
- Offer Ads - Ads promting an offer.
- Bidding and Optimization - How bidding and budgeting works.
- Targeting - Reach the right audience.
- Instagram Ads
facebook api之Marketing API的更多相关文章
- 今日头条Marketing API小工具(.Net Core版本)
前言 由于工作原因,需要用到今日头条的Marketing API做一些广告投放的定制化开发.然后看现在网上也没多少关于头条Marketing API的文章,于是便就有了该篇文章. 头条Marketin ...
- criteo marketing api 相关
官网登陆地址:https://marketing.criteo.com/ 官网api介绍:https://marketing.criteo.com/e/s/article?article=360001 ...
- harbor rest api 转graphql api
原理 实际上就是使用graphql 中的binding,首先基于swagger api 进行schema 生成,后边就是 使用binding 进行graphql 请求api 转换为rest api 请 ...
- API网关在API安全性中的作用
从单一应用程序切换到微服务时,客户端的行为不能与客户端具有该应用程序的一个入口点的行为相同.简单来说就是微服务上的某一部分功能与单独实现该应用程序时存在不同. 目前在使用微服务时,客户端必须处理微服务 ...
- 用API网关把API管起来
最开始只是想找个API网关防止API被恶意请求,找了一圈发现基于Nginx的OpenResty(Lua语言)扩展模块Orange挺好(也找了Kong,但是感觉复杂了点没用),还偷懒用Vagrant结合 ...
- lumen 构建api(dingo api)
什么是 API API(Application Programming Interface,应用程序编程接口)是一些预先定义的函数,目的是提供应用程序与开发人员基于某软件或硬件得以访问一组例程的能力, ...
- ASP.NET Core Web API 开发-RESTful API实现
ASP.NET Core Web API 开发-RESTful API实现 REST 介绍: 符合REST设计风格的Web API称为RESTful API. 具象状态传输(英文:Representa ...
- 通过beego快速创建一个Restful风格API项目及API文档自动化
通过beego快速创建一个Restful风格API项目及API文档自动化 本文演示如何快速(一分钟内,不写一行代码)的根据数据库及表创建一个Restful风格的API项目,及提供便于在线测试API的界 ...
- HTML5之本地文件系统API - File System API
HTML5之本地文件系统API - File System API 新的HTML5标准给我们带来了大量的新特性和惊喜,例如,画图的画布Canvas,多媒体的audio和video等等.除了上面我们提到 ...
随机推荐
- 查看完整的 Unicode 字符集
https://unicode-table.com/cn/ 这个链接是我想要查的 格式如下图 先放这里收藏,我也不知道怎么搜索
- Python: 字典dict: 相同点
问题:怎么样在两个字典中找相同点 answer: eg1: 下面2个字典 a={'x':1,'y':2,'z':3}, b={'w':10,'x':11,'y':2}, 1)找相同点: a.ke ...
- c# 共享事件处理程序
使用同一个方法来处理多个Button实例的Click事件. 1.全选所有的Button,在事件添加中的Click点击事件中添加处理函数. 2.假如一个label控件用于显示按钮按下输出文本 3.处理函 ...
- Web 应用架构基础课(转载)
Web 应用架构基础课 初级 web 应用开发者必学的基础网络架构概念 web 应用主流架构概览 上图便是我司(Storyblocks)网络架构的很好展现.如果你还没成为经验老道的 web 工程师,可 ...
- 转:[你必须知道的异步编程]——异步编程模型(APM)
本专题概要: 引言 你知道APM吗? 你想知道如何使用异步编程模型编写代码吗? 使用委托也可以实现异步编程,你知道否? 小结 一.引言 在前面的C#基础知识系列中介绍了从C#1.0——C#4.0中一些 ...
- bzoj4448 情报传递
题目链接 离线+树上主席树,主席树维护时间标记 注意查询时如果c<0要把c赋为0: #include<iostream> #include<cstdio> #includ ...
- [C#基础]说说lock到底锁谁?(补充与修改)
摘要 今天在园子里面有园友反馈关于[C#基础]说说lock到底锁谁?文章中lock(this)的问题.后来针对文章中的例子,仔细想了一下,确实不准确,才有了这篇文章的补充,已经对文章中的demo进行修 ...
- [转载]SQL中EXISTS的用法
比如在Northwind数据库中有一个查询为SELECT c.CustomerId,CompanyName FROM Customers cWHERE EXISTS(SELECT OrderID FR ...
- Java学习路线教程之JDBC基本操作
为了帮助大家熟练应用JDBC编程,接下来,在本节将通过一个综合案例来讲解JDBC的基本操作,确保大家能够深刻理解JDBC的增.删.改.查,灵活利用JDBC完成对数据库的各项操作. 1. 创建一个Jav ...
- flask框架----flask-script组件
Flask Script扩展提供向Flask插入外部脚本的功能,包括运行一个开发用的服务器,一个定制的Python shell,设置数据库的脚本,cronjobs,及其他运行在web应用之外的命令行任 ...