38

Edit: I've managed to get this far in the documentation: https://developers.facebook.com/docs/graph-api/reference/v2.5/promotion-info

However there's nothing linking to the {promotion-info-id} parameter in the docs that I could find.

I'll accept an answer with code/API references that's not specific to PHP as well.

I'm trying to fetch my users pages and posts insights which are working as expected, however I also need to receive stats such as per 1000 reached (cpm), total spent and new fan costs.

I am able to receive all user pages and posts however the insights API doesn't return any associated costs. I've looked at the Marketing API, but can't figure out how to link the pages and posts to those stats. How do I get the ad_account/ad_campaign values from posts and pages? Do I need them at all? Feeling quite lost in its API.

I also need to fetch the stats on a daily basis in order to calculate daily and monthly changes.

I can pull most daily stats using the insights API but there are no costs attached and https://developers.facebook.com/docs/graph-api/reference/v2.5/page nor https://developers.facebook.com/docs/graph-api/reference/v2.5/post offers no such thing.

$response = $this->facebook->get('/' . $pageId . '/insights?since=' . date('Y-m') . '-01', $token);
$data = $response->getGraphEdge()->asArray();

Also, is there a facebook sandbox I could use to pull dummy costs or other stats since I don't have a page that would have paid content.

Ignas
  • 1,965
  • 2
  • 17
  • 44
  • @DaniSpringer.com what I meant was, that even though my project is written in PHP, I'm happy to look at implementations in languages other than PHP:) – Ignas Apr 21 '16 at 07:00

2 Answers2

2

You can get the Ads Insights using the Facebook Marketing API Insights Edge. There is really many data you can crawl, but unfortunately there is no way to connect them to the posts due to the Facebook ads nature.

If you want to you can try to create ads using Marketing API Ads Managment Edge with data grabbed from your posts and than track these ads.

But there is really no other way.

-1

I don't really understand what you are asking for. Do you want all the costs you had for ads, per specific Page? If that's the case; you can't retrieve that. The costs are provided per ad campaign/set/group, not on Page/Post level.

Roemer
  • 3,566
  • 1
  • 16
  • 32
  • 1
    I need to get the sponsored post costs and based on that calculate how much the page has spent promoting itself. – Ignas Nov 02 '15 at 11:24
  • You will have to use the ad objects as an "entrypoint" for that. There is no way to directly retrieve that from a Page/Post through the API. – Roemer Nov 02 '15 at 12:23
  • Could you reference the required API endpoints or links to docs? What's the workflow here? – Ignas Nov 02 '15 at 14:59
  • 1
    I think you don't understand me; you will have to use the ads insights edges to get cost data. There is no canonical way to relate it to a Page or a Post directly. You will have to traverse your ads. – Roemer Nov 02 '15 at 21:04