Skip to content

Commit

Permalink
Update fbGetAdAccounts.R
Browse files Browse the repository at this point in the history
  • Loading branch information
selesnow authored Oct 13, 2017
1 parent fa12b12 commit b5138ee
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/fbGetAdAccounts.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ fbGetAdAccounts <- function(source_id = NULL, api_version = "v2.10", access_toke
result <- data.frame(stringsAsFactors = FALSE)

#Compose query string
QueryString <- paste0("https://graph.facebook.com/",api_version,"/",source_id,"/adaccounts?&fields=name,id,account_id,account_status,user_role,age,business_name,amount_spent,balance,currency,business_city,business_country_code&limit=100&access_token=",access_token)
QueryString <- paste0("https://graph.facebook.com/",api_version,"/",source_id,"/adaccounts?&fields=name,id,account_id,account_status,user_role,age,business,owner,partner,amount_spent,spend_cap,balance,currency,business_city,business_country_code&limit=100&access_token=",access_token)

#Send query to API server
answer <- GET(QueryString)

#Parse result
raw <- fromJSON(content(answer, "text", "application/json",encoding = "UTF-8"))
raw <- fromJSON(content(answer, "text", "application/json",encoding = "UTF-8"),flatten = T)

#Check error
if(!is.null(raw$error)){
Expand All @@ -34,7 +34,7 @@ result <- rbind(result, raw$data)
while(!is.null(raw$paging$`next`)){
QueryString <- raw$paging$`next`
answer <- GET(QueryString)
raw <- fromJSON(content(answer, "text", "application/json",encoding = "UTF-8"))
raw <- fromJSON(content(answer, "text", "application/json",encoding = "UTF-8"),flatten = T)
result <- rbind(result, raw$data)}

return(result)}
return(result)}

0 comments on commit b5138ee

Please sign in to comment.