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

error while using through Azure R notebook #53

Closed andreifoldes closed 7 years ago

andreifoldes commented 7 years ago

I would to use the package in a Microsoft Azure R Notebook, however after

mystats<-fb_insights(date_preset='last_7_days', level='campaign',
                     fields= toJSON(c('campaign_name', 'reach','impressions','clicks','spend')), time_increment=1)

it returns...

ERROR [2017-04-20 13:21:22] URL:  https://graph.facebook.com/v2.8/act_554605768056065/
ERROR [2017-04-20 13:21:22] Method:  GET
ERROR [2017-04-20 13:21:22] Params:  List of 1
 $ fields: chr "name,account_id,account_status,age,amount_spent,balance,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: Received HTTP code 403 from proxy after CONNECT
Traceback:

1. fbad_init(accountid = accountid, token = tkn.at, version = "2.8")
2. fbad_get_adaccount_details(accountid, token, version)
3. fbad_request(path = paste0("act_", accountid, "/"), method = "GET", 
 .     params = list(access_token = token, fields = scope), version = version)
4. stop(paste(ifelse(inherits(curlres, "error"), "This is a bug in the fbRads package. Please report on GitHub with a detailed output:", 
 .     "FB query failed:"), res$message))
daroczig commented 7 years ago

Based on the HTTP response (403), I don't think it's an fbRads issue -- but rather an Azure firewall limitations. See eg the below threads:

So I think there's a whitelist for allowed domains (eg GitHub) where you can make connections from a notebook, but the Facebook Graph API is not among those.

Can you please double check? Eg a prior fbad_init function runs without any problems?

andreifoldes commented 7 years ago

Hello,

Seems plausible, thanks for pointing that out; fbad_init runs with no problems

daroczig commented 7 years ago

Hm, then https://graph.facebook.com is whitelisted, as the fbad_init function uses the same graph.facebook.com domain for the API endpoint. Do you always get this error whenever you try to run fb_insights? Did you try any other fbRads functions?

daroczig commented 7 years ago

Seems to be related to Azure firewall and not really a problem in the package, but please reopen if that's not the case.