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
153 stars 57 forks source link

Authentication isssues #63

Closed lucasdedavid closed 7 years ago

lucasdedavid commented 7 years ago

Hey, I've been trying to use the package to integrate some data and i'm having some trouble with auth.

When fbad_init("account", token), I get this error:

ERROR [2017-07-17 16:56:04] URL:  https://graph.facebook.com/v2.5/act_1873405082881571/
ERROR [2017-07-17 16:56:04] Method:  GET
ERROR [2017-07-17 16:56:04] Params:  List of 1
 $ fields: chr "name,account_id,account_status,age,amount_spent,balance,capabilities,end_advertiser,funding_source,spend_cap,timezone_id,users"
Error in fbad_request(path = paste0("act_", accountid, "/"), method = "GET",  : 
  This is a bug in the fbRads package. Please report on GitHub with a detailed output: SSL: CA certificate set, but certificate verification is disabled
Além disso: Warning message:
In curlSetOpt(..., .opts = .opts, curl = h, .encoding = .encoding) :
  Error setting the option for # 2 (status = 4) (enum = 10097) (value = 0x101aec890): A requested feature, protocol or option was not found built-in in this libcurl due to a build-time decision. <not set>

Can somebody help me to authenticate?

daroczig commented 7 years ago

It seems you are using a very old version of the package (probably from CRAN) -- can you please check the dev version installed from GitHub?

devtools::install_github('daroczig/fbRads')

Please reopen if you still cannot auth.

lucasdedavid commented 7 years ago

Still having trouble. Your hint helped me but when listing ad: fbad_list_ad("1355059354571137", id, statuses, fields = "id") I get: Error in fbad_check_fbacc() : Invalid R object passed as fbacc argument. See ?fbad_init for more details. Checked the account and it's right.

daroczig commented 7 years ago

Try

fbad_list_ad(id = "1355059354571137", fields = "id")

The first arg of fbad_list_ad (and all fbad functions) is the fbacc object, that is automatically populated if not specified, but you have to use named args. I might get rid of that arg after all, but not not in the next few weeks

lucasdedavid commented 7 years ago
Error in fbad_request(fbacc, path = file.path(id, endpoint), params = params,  : 
  Unsupported get request. Object with ID '1355059354571137' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api
lucasdedavid commented 7 years ago

Done :) Had to input act_ before the id

lucasdedavid commented 7 years ago

Now I'm having some trouble in setting the fields on FB API.

fbad_read_ad(id= "23842609228480736", fields = c("name", "created_time", "status"))

This code is ok, but when I add some fields of FB documentation I get

Error in fbad_request(fbacc, path = id, params = list(fields = fields), : (#100) Tried accessing nonexisting field (creative) on node type (AdCampaign)

And also, I see no way to get impressions, reach, views and other metrics on the API. Can somebody help me with this?

daroczig commented 7 years ago

That FB error message seems to provide a pretty good explanation on what your are doing wrong: trying to query the creative of an ad campaign, but that field is associated with the ad level. Read the FB docs, at this point, I think that will be the most helpful.

lucasdedavid commented 7 years ago

One more thing: When I enter

fb_insights(date_preset="today", level = "ad", toJSON(c(fields="impressions")))

I get ``` Error in fbad_check_fbacc() : Invalid R object passed as fbacc argument. See ?fbad_init for more details.

daroczig commented 7 years ago

You again forgot about named arguments