daroczig / fbRads

Analyze and manage Facebook ads from R using this client library to access their Marketing APIs
GNU Affero General Public License v3.0
151 stars 57 forks source link

Listing Issue #114

Closed Sahil005 closed 5 years ago

Sahil005 commented 5 years ago

I'm not aware of such limitation in fbRads, it should work with any valid token. Can you share your devtools::session_info() output?

Originally posted by @daroczig in https://github.com/daroczig/fbRads/issues/98#issuecomment-409862745

Sahil005 commented 5 years ago

I'm Also getting an error token <- "****"

accounts <- fbad_get_my_ad_accounts(token, version = '3.2')

account <- head(accounts$account_id,1)

init <- fbad_init(accountid = account, token, version = '3.2')

ab <- fbad_list_campaign(init,fields = c('Campaign ID','Campaign Name','Campaign Status','Reach','Impressions','Cost per result','Amount Spent','Link Clicks'))

when i'm running this code,i'm getting an error like this

ab <- fbad_listcampaign(init,fields = c('Campaign ID','Campaign Name','Campaign Status','Reach','Impressions','Cost per result','Amount Spent','Link Clicks')) ERROR [2018-12-27 22:08:29] URL: https://graph.facebook.com/v3.2/act****/campaigns ERROR [2018-12-27 22:08:29] Method: GET ERROR [2018-12-27 22:08:29] Params: List of 2 $ fields: chr "Campaign ID,Campaign Name,Campaign Status,Reach,Impressions,Cost per result,Amount Spent,Link Clicks" $ limit : num 1000 ERROR [2018-12-27 22:08:29] Header: {"x-app-usage":["{\"call_count\":0,\"total_cputime\":0,\"total_time\":0}"],"WWW-Authenticate":["OAuth \"Facebook Platform\" \"invalid_request\" \"Syntax error \\"Expected end of string instead of \\"I\\".\\" at character 9: Campaign ID,Campaign Name,Campaign Status,Reach,Impressions,Cost per result,Amount Spent,Link Clicks\""],"Content-Type":["application/json; charset=UTF-8"],"facebook-api-version":["v3.2"],"x-fb-rev":["4656655"],"Access-Control-Allow-Origin":["*"],"Cache-Control":["no-store"],"x-fb-trace-id":["GYAXiUnxusG"],"Expires":["Sat, 01 Jan 2000 00:00:00 GMT"],"Strict-Transport-Security":["max-age=15552000; preload"],"Pragma":["no-cache"],"X-FB-Debug":["si20QyYSMIwFdpbnj8BWDuSQfQ8EO9rzqpdRLdZL7nbc5hPt25M9mTGe+4dueNn7kD1AwLMOB/nKfDQzyEJxVQ=="],"Date":["Thu, 27 Dec 2018 16:38:28 GMT"],"Connection":["keep-alive"],"Content-Length":["261"],"status":["400"],"statusMessage":["Bad Request"]} ERROR [2018-12-27 22:08:29] Body: {"error":{"message":"Syntax error \"Expected end of string instead of \"I\".\" at character 9: Campaign ID,Campaign Name,Campaign Status,Reach,Impressions,Cost per result,Amount Spent,Link Clicks","type":"OAuthException","code":2500,"fbtrace_id":"GYAXiUnxusG"}} Error in fbad_request(fbacc, path = file.path(id, endpoint), params = params, : Syntax error "Expected end of string instead of "I"." at character 9: Campaign ID,Campaign Name,Campaign Status,Reach,Impressions,Cost per result,Amount Spent,Link Clicks

what will be the possible reason?

daroczig commented 5 years ago

You are using wrong field names, pls check the docs https://developers.facebook.com/docs/marketing-api/reference/ad-campaign-group#Reading

Sahil005 commented 5 years ago

You are using wrong field names, pls check the docs https://developers.facebook.com/docs/marketing-api/reference/ad-campaign-group#Reading

I've used these docs names later on as well but don't get the results and getting the same error and i even can't find the columns of reach,impressions and all other important stats,how can i do that.. may be the reason on the API hitting on backend and i can't edit the API... please tell me how to include these variables(reach,impressions,ctr,cpc,etc) in fbad_get_my_ad_accounts functions in fbRads package...please help asap...

daroczig commented 5 years ago

I guess you need the Insights API endpoint and the fb_insights function, but most importantly I'd suggest you reading the FB docs and checking the slides of fbRads, otherwise you will not be really able to make much progress.