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

Encoding issues when pulling fields with creative fbad_read_creative #111

Closed emadretina closed 5 years ago

emadretina commented 6 years ago

This was one of the original issues I had with this package. For some reason when trying to pull image_url I sometimes run into encoding/decoding issues.

For example when I run the following for certain ads :

creative <- fbRads::fbad_read_creative(id = ctad, by = c("ad"), fields = c("id", "name", "title", "run_status", "actor_id", "call_to_action_type", "follow_redirect", "image_file", "image_hash", "image_url", "thumbnail_url", "link_url", "url_tags", "object_id", "object_story_id", "object_type", "object_url","body", "video_id"))

I get the following error:

ERROR [2018-11-04 19:28:38] URL: https://graph.facebook.com/v3.0/6107186323913/adcreatives?fields=id,name,title,run_status,actor_id,call_to_action_type,follow_redirect,image_file,image_hash,image_url,thumbnail_url,link_url,url_tags,object_id,object_story_id,object_type,object_url,body ERROR [2018-11-04 19:28:38] URL: https://graph.facebook.com/v3.0/6107186232113/adcreatives?fields=id,name,title,run_status,actor_id,call_to_action_type,follow_redirect,image_file,image_hash,image_url,thumbnail_url,link_url,url_tags,object_id,object_story_id,object_type,object_url,body ERROR [2018-11-04 19:28:38] URL: https://graph.facebook.com/v3.0/6107186707313/adcreatives?fields=id,name,title,run_status,actor_id,call_to_action_type,follow_redirect,image_file,image_hash,image_url,thumbnail_url,link_url,url_tags,object_id,object_story_id,object_type,object_url,body ERROR [2018-11-04 19:28:38] URL: https://graph.facebook.com/v3.0/6107186707113/adcreatives?fields=id,name,title,run_status,actor_id,call_to_action_type,follow_redirect,image_file,image_hash,image_url,thumbnail_url,link_url,url_tags,object_id,object_story_id,object_type,object_url,body ERROR [2018-11-04 19:28:38] Method: GET ERROR [2018-11-04 19:28:38] Params: Named list() Error in fbad_request(fbacc, path = switch(by, creative = paste0(id, "?fields=", : This is a bug in the fbRads package. Please report on GitHub with a detailed output: Could not resolve host: �\�

Session Info:

`Session info -------------------------------------------------------------------------------------- setting value
version R version 3.5.0 (2018-04-23) system x86_64, darwin15.6.0
ui RStudio (1.1.447)
language (EN)
collate en_US.UTF-8
tz America/Los_Angeles
date 2018-11-05

Packages ------------------------------------------------------------------------------------------ package version date source
assertthat 0.2.0 2017-04-11 CRAN (R 3.5.0)
backports 1.1.2 2017-12-13 CRAN (R 3.5.0)
base
3.5.0 2018-04-24 local
bindr 0.1.1 2018-03-13 CRAN (R 3.5.0)
bindrcpp 0.2.2 2018-03-29 CRAN (R 3.5.0)
bit 1.1-14 2018-05-29 cran (@1.1-14)
bit64 0.9-7 2017-05-08 cran (@0.9-7)
bitops 1.0-6 2013-08-17 CRAN (R 3.5.0)
broom 0.5.0 2018-07-17 cran (@0.5.0)
cellranger 1.1.0 2016-07-27 CRAN (R 3.5.0)
cli 1.0.0 2017-11-05 CRAN (R 3.5.0)
colorspace 1.3-2 2016-12-14 CRAN (R 3.5.0)
compiler 3.5.0 2018-04-24 local
crayon 1.3.4 2017-09-16 CRAN (R 3.5.0)
data.table 1.11.8 2018-09-30 cran (@1.11.8)
datasets 3.5.0 2018-04-24 local
devtools 1.13.6 2018-06-27 CRAN (R 3.5.0)
digest 0.6.18 2018-10-10 CRAN (R 3.5.0)
dplyr
0.7.7 2018-10-16 cran (@0.7.7)
fbRads 3.0.0 2018-10-28 Github (daroczig/fbRads@2c08d3e) forcats 0.3.0 2018-02-19 CRAN (R 3.5.0)
formatR 1.5 2017-04-25 cran (@1.5)
futile.logger 1.4.3 2016-07-10 cran (@1.4.3)
futile.options 1.0.1 2018-04-20 cran (@1.0.1)
ggplot2 3.1.0 2018-10-25 cran (@3.1.0)
glue 1.3.0 2018-07-17 cran (@1.3.0)
graphics
3.5.0 2018-04-24 local
grDevices 3.5.0 2018-04-24 local
grid 3.5.0 2018-04-24 local
gtable 0.2.0 2016-02-26 CRAN (R 3.5.0)
haven 1.1.2 2018-06-27 cran (@1.1.2)
hms 0.4.2 2018-03-10 CRAN (R 3.5.0)
httr 1.3.1 2017-08-20 CRAN (R 3.5.0)
jsonlite 1.5 2017-06-01 CRAN (R 3.5.0)
lambda.r 1.2.3 2018-05-17 cran (@1.2.3)
lattice 0.20-35 2017-03-25 CRAN (R 3.5.0)
lazyeval 0.2.1 2017-10-29 CRAN (R 3.5.0)
lubridate 1.7.4 2018-04-11 CRAN (R 3.5.0)
magrittr 1.5 2014-11-22 CRAN (R 3.5.0)
memoise 1.1.0 2017-04-21 CRAN (R 3.5.0)
methods
3.5.0 2018-04-24 local
modelr 0.1.2 2018-05-11 CRAN (R 3.5.0)
munsell 0.5.0 2018-06-12 cran (@0.5.0)
nlme 3.1-137 2018-04-07 CRAN (R 3.5.0)
pillar 1.2.2 2018-04-26 CRAN (R 3.5.0)
pkgconfig 2.0.2 2018-08-16 cran (@2.0.2)
plyr 1.8.4 2016-06-08 CRAN (R 3.5.0)
purrr 0.2.5 2018-05-29 cran (@0.2.5)
R6 2.3.0 2018-10-04 cran (@2.3.0)
Rcpp 0.12.19 2018-10-01 cran (@0.12.19)
RCurl 1.95-4.11 2018-07-15 cran (@1.95-4.)
readr
1.1.1 2017-05-16 CRAN (R 3.5.0)
readxl 1.1.0 2018-04-20 CRAN (R 3.5.0)
rlang 0.3.0.1 2018-10-25 cran (@0.3.0.1)
rstudioapi 0.8 2018-10-02 cran (@0.8)
rvest 0.3.2 2016-06-17 CRAN (R 3.5.0)
scales 1.0.0 2018-08-09 cran (@1.0.0)
stats 3.5.0 2018-04-24 local
stringi 1.2.4 2018-07-20 cran (@1.2.4)
stringr
1.3.1 2018-05-10 CRAN (R 3.5.0)
tibble 1.4.2 2018-01-22 CRAN (R 3.5.0)
tidyr
0.8.1 2018-05-18 cran (@0.8.1)
tidyselect 0.2.5 2018-10-11 cran (@0.2.5)
tidyverse 1.2.1 2017-11-14 CRAN (R 3.5.0)
tools 3.5.0 2018-04-24 local
utils
3.5.0 2018-04-24 local
withr 2.1.2 2018-03-15 CRAN (R 3.5.0)
xml2 1.2.0 2018-01-24 CRAN (R 3.5.0)
yaml 2.2.0 2018-07-25 cran (@2.2.0) `

daroczig commented 6 years ago

Haven't seen this issue so far. Can you share your devtools::session_info()? Also, if you could run debugonce on fbad_read_creative before running the above query and check what might be causing that issue in the returned JSON file, that would be great. Although I'm confused by the Could not resolve host error message a bit.

emadretina commented 6 years ago

Added, session info above. And unfortunately, the debugonce didn't work, as in it failed to enter debug mode.

`debugonce(

daroczig commented 6 years ago

Sorry for the confusion about debugonce -- you should call that on the function name, then do the actual function call, eg:

debugonce(fbRads::fbad_read_creative)
fbRads::fbad_read_creative(...)

Then pressing the enter you can evaluate the body of the function line by line. After you get to the fbad_request point, check the content of res -- I'd love to see what's causing this issue there.

daroczig commented 5 years ago

Closing as I cannot reproduce and did not get any more info.