hi.
I made this little code so they can get the total cost of a campaign. With this information they can develop their own script and automate for see coherent statistics in your tracker
sure they will say that this code is irrelevant, but think of the possibilities. copy and paste your daily spending and run update spending is not the best way.
I share what I did.
I did the script to
with cronjobs rule can make it run at the end of the day
// Facebook variables $fb->token = 'access token'; $fb->camp = 'id campaign'; //Thrive variables $thrive->apiKey = 'xxxx'; $thrive->apiSecret = 'xx'; $thrive->base = 'domain.com/thrive'; $thrive->timeZone = 'your time zone. example: America/Lima'; $thrive->camp = 'id thrive campaign';
step 1:
https://www.facebook.com/dialog/oauth?client_id={app_id}&redirect_uri=http://domain.com/&scope=ads_management,manage_pages
enter this link, redirect to dominio.com/?code=XXXXXX
copy XXXXX
step 2:
https://graph.facebook.com/v2.4/oauth/access_token?client_id={app_id}&redirect_uri=http://domain.com/&client_secret={app_secret}&code=XXXXXX
return {"access_token":"YYYYYYYYYYYYYYYYYYYYY","token_type":"bearer"}
copy YYYYYYYYYYYYYYYYYYYYY
step 3: (access token long live)
https://graph.facebook.com/v2.4/oauth/access_token?grant_type=fb_exchange_token&client_id={app_id}&client_secret={app_secret}&fb_exchange_token=YYYYYYYYYYYYYYYYYYYYY
enter this link, copy access token final.