在后台下载Facebook广告统计资料(无网页浏览器) [英] Downloading Facebook ads statistics in background (no web browser)

查看:232
本文介绍了在后台下载Facebook广告统计资料(无网页浏览器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个后台服务器应用程序,该应用程序应该向广告客户发送广告活动统计数据,这些广告活动统计信息由各种提供商捆绑在一起,其中一个是Facebook。



现在的问题是如何从Facebook下载特定的广告系列。基本上,我需要的是一个具体广告系列的表格,每个请求范围的每一天都会有展示次数和点击次数。



一个问题是应用程序是后台服务器进程,正在运行定期没有用户互动,所以我怀疑身份验证可能会有问题。



从目前为止我已经阅读过,我相信我应该是




  • 在Facebook上注册我的应用程序

  • 申请广告API访问(?)

  • 使用传统的REST API来获取统计信息,或者可以使用图形API进行adsstatistics(但是我相信格式在特定日子里没有分割)。



在这种情况下,我应该如何进行身份验证?



任何关于这里的正确解决方案的建议?



(注意:在过去,我和Google类似,我已成功使用 http://code.google.com/intl/cs/apis/adwords/docs/guides/reporting.html - 这只是为了参考我需要什么

解决方案

如果您有Ads API访问权限,请查看此页面进行身份验证:
http://developers.facebook.com/docs/authentication/



最后,您将需要一个access_token,该访问特定于您的应用程序和您正在访问的Facebook帐户。



以下是我们的过程:


  1. 登录包含广告数据的Facebook帐户

  2. 将其粘贴到该浏览器的地址栏中:
    https://www.facebook.com/dialog/oauth?client_id= {your_application_id}& scope = ads_management,offline_access,read_insights& redirect_uri = {your
    website}

  3. 你应该被带到一个允许你
    授权你的ap (绿色
    允许按钮)

  4. code = 之后出现的授权码复制到重定向网址

  5. 将此粘贴​​到浏览器的地址栏中(如果您没有使用client_secret,则不会尝试使用client_secret):
    https://graph.facebook.com/oauth/access_token?client_id= {your_application_id}& redirect_uri = {your website}& client_secret = {your application secret}& code = {code you got
    从步骤4}

  6. 你应该被带到包含access_token的页面

我不认为您需要存储授权代码,因为access_token不应该过期(如果您请求offline_access),除非Facebook帐户的登录信息已更改。



统计检索
对于统计检索,我不会使用旧版REST API,因为Facebook会贬值。 Graph API确实允许按日检索统计信息,使用:



GET https://graph.facebook.com/stats/ {starttime} / { endtime} / stats?ids = {campaign_id}& access_token = ...



开始时间和结束时间可以在YYYY-MM-DD HH:MM:SS格式或unix(纪元?)时间


I am developing a backoffice server application wich is supposed to email our customers with ads campaign statitistics, where camapaigns are bundled from various providers, one of them being Facebook.

Now the problem is how to download specific ads campaigns from Facebook. Basically what I need is a table for specific campaign with values for impressions and clicks for each day from requested range.

One problem is that the application is background server process, running periodically without user interactions, so I suspect there could be a problem with authentication.

From what I have read so far, I believe I am supposed to

  • register my application on facebook
  • apply for Ads API access (?)
  • use either legacy REST API to get statistics, or perhaps adsstatistics from graph api (but I believe that the format there is not divided for particular days).

How am I supposed to authenticate in this case?

Any suggestion as to what is the right solution here?

(Note: In the past, I was doing similiar for Google, where I have successfully used http://code.google.com/intl/cs/apis/adwords/docs/guides/reporting.html - this is just for reference about what I need to achieve).

解决方案

See this page for authentication once you have Ads API access: http://developers.facebook.com/docs/authentication/

In the end you'll need an access_token which is specific to your application and the Facebook account you are accessing.

Here's our process:

  1. Log into Facebook account that contains the ads data
  2. Paste this into that browser's address bar: https://www.facebook.com/dialog/oauth?client_id={your_application_id}&scope=ads_management,offline_access,read_insights&redirect_uri={your website}
  3. You should be taken to a page that allows you to authorize your application for that Facebook account (green Allow button)
  4. Copy the authorization code that appears after code= in the redirected url
  5. Paste this into that browser's address bar (you may not have a client_secret with your application, if you don't try this without the client_secret): https://graph.facebook.com/oauth/access_token?client_id={your_application_id}&redirect_uri={your website}&client_secret={your application secret}&code={code you got from step 4}
  6. You should be taken to a page containing the access_token

I do not think you need to store the Authorization code since the access_token shouldn't expire (if you requested offline_access) unless the log in info is changed for the Facebook Account.

Stats Retrieval For stats retrieval, I would not use legacy REST API since Facebook will depreciate it. Graph API does allow stats retrieval by day, use:

GET https://graph.facebook.com/stats/{starttime}/{endtime}/stats?ids={campaign_id}&access_token=...

starttime and endtime can be in YYYY-MM-DD HH:MM:SS format or as a unix (epoch?) time

这篇关于在后台下载Facebook广告统计资料(无网页浏览器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆