I have installed themify WordPress theme and created a home page in it locally. Google map is giving the following error in JavaScript console.
util.js:210 Google Maps API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keysTA.j # util.js:210(anonymous function) # js?sensor=false&ver=4.6.1:126(anonymous function) # js?sensor=false&ver=4.6.1:46(anonymous function) # js?sensor=false&ver=4.6.1:43(anonymous function) # js?sensor=false&ver=4.6.1:46(anonymous function) # js?sensor=false&ver=4.6.1:98(anonymous function) # js?sensor=false&ver=4.6.1:43(anonymous function) # js?sensor=false&ver=4.6.1:98hc # js?sensor=false&ver=4.6.1:45gc.wb # js?sensor=false&ver=4.6.1:98(anonymous function) # stats.js:1
util.js:210 Google Maps API warning: SensorNotRequired https://developers.google.com/maps/documentation/javascript/error-messages#sensor-not-requiredTA.j # util.js:210(anonymous function) # js?sensor=false&ver=4.6.1:126(anonymous function) # js?sensor=false&ver=4.6.1:46(anonymous function) # js?sensor=false&ver=4.6.1:43(anonymous function) # js?sensor=false&ver=4.6.1:46(anonymous function) # js?sensor=false&ver=4.6.1:98(anonymous function) # js?sensor=false&ver=4.6.1:43(anonymous function) # js?sensor=false&ver=4.6.1:98hc # js?sensor=false&ver=4.6.1:45gc.wb # js?sensor=false&ver=4.6.1:98(anonymous function) # stats.js:1
VM23938:1 'webkitIDBTransaction' is deprecated. Please use 'IDBTransaction' instead.(anonymous function) # VM23938:1a.S # VM23904:1V # VM23904:1F # VM23904:1botguard.bg # VM23904:1(anonymous function) # www-embed-player.js:123g # www-embed-player.js:108
js?sensor=false&ver=4.6.1:34 Google Maps API error: MissingKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error_.kb # js?sensor=false&ver=4.6.1:34(anonymous function) # common.js:50(anonymous function) # common.js:203c # common.js:44(anonymous function) # AuthenticationService.Authenticate?1shttp%3A%2F%2Flocalhost%2Frdxcorporate%2Faffiliate-clubs%2F&cal…:1
I am unable to find the location where I can put the api key.
This has been documented in the Themify documentation:
Google recently requires users to create an API key in order to use
Google Map. To fix this go to
https://developers.google.com/maps/documentation/javascript/get-api-key,
then copy your API key and paste it in Themify > Settings > Google
Maps page.
Related
I'm trying to add a custom definition to one of my GA4 properties and I'm getting this error in the attached image. The weird thing is that I've been able to add the same definition in another GA4 property without issues.
(https://i.stack.imgur.com/Ixbrp.png)
POST https://analytics.google.com/analytics/app/data/v2/reporting/customdefinitions/user?dataset=a55955706p326566624&gamonitor=gafe&hl=en_US&state=app.admin.mobile.customdefinitions.hub 500
l # m=chunk_base_lazy:5033
r.scheduleTask # m=chunk_base_lazy:4995
zua # m=chunk_base_lazy:4992
r.scheduleTask # m=chunk_base_lazy:4995
n.scheduleTask # m=chunk_base_lazy:4989
n.scheduleMacroTask # m=chunk_base_lazy:4990
(anonymous) # m=chunk_base_lazy:5034
d.<computed> # m=chunk_base_lazy:285
(anonymous) # VM327:134
w # VM327:129
(anonymous) # VM327:126
(anonymous) # VM327:161
$digest # VM327:172
(anonymous) # m=chunk_base_lazy:5236
_.ga4.SAb # m=chunk_base_lazy:5067
_.ga4.next # m=chunk_base_lazy:5066
_.ga4.Sc # m=chunk_base_lazy:5064
_.ga4.next # m=chunk_base_lazy:5064
_.ga4.next # m=chunk_base_lazy:5069
_.ga41.emit # m=chunk_base_lazy:5097
ga4$fa # m=chunk_base_lazy:426
Hfa # m=chunk_base_lazy:427
r.Hea # m=chunk_base_lazy:4995
n.runTask # m=chunk_base_lazy:4988
t.Hea # m=chunk_base_lazy:4997
p # m=chunk_base_lazy:297
e # m=chunk_base_lazy:288
r # m=chunk_base_lazy:297
m=chunk_base_lazy:5043
ERROR Error: ba`Object: {"data":{"er":{"errorCode":13,"httpStatus":500},"di":{"serverTime":"46","serverTick":[],"rpcInfo":[],"logRecord":[],"graphInfo":[],"responseExtension":[]}},"status":500,"config":{"method":"POST","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","resourceName":"CustomDefinitions:User","resourceOperation":"Create","params":{"dataset":"a55955706p326566624","hl":"en_US","gamonitor":"gafe","state":"app.admin.mobile.customdefinitions.hub"},"url":"/analytics/app/data/v2/reporting/customdefinitions/user","data":{"paramName":"sample_custom_dimension","scope":1,"description":"Sample custom dimension description","definitionType":0,"displayName":"Sample Custom Dimension"},"headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json;charset=utf-8","X-GAFE4-XSRF-TOKEN":"AO6Y7m9xu6pRyxTN5JDl-S7XvhE8SMg43Q:1675874089894"},"uid":"/analytics/app/data/v2/reporting/customdefinitions/user74"},"statusText":"","xhrStatus":"complete"}`
at f (m=chunk_base_lazy:5001:29)
at k (m=chunk_base_lazy:5011:156)
at k (m=chunk_base_lazy:5010:221)
at m=chunk_base_lazy:5012:241
at r.Hea (m=chunk_base_lazy:4996:21)
at Object.Hfa (m=chunk_base_lazy:427:130)
at r.Hea (m=chunk_base_lazy:4995:485)
at n.runTask (m=chunk_base_lazy:4988:141)
at g (m=chunk_base_lazy:4984:3554)
at t.Hea [as invoke] (m=chunk_base_lazy:4997:402)
at p (m=chunk_base_lazy:297:15)
at e (m=chunk_base_lazy:288:246)
at XMLHttpRequest.r (m=chunk_base_lazy:297:171)
I've added this same dimension successfully to other GA4 properties late last year, but now I cannot add this dimension to a different GA4 property.
I save two lists as ".RData" in the my_package/data and have their documentation in /R. But after installation, I cannot load those two lists but it shows the help documentation.
Is it possible to export a list in a R package? Or just able to matrix or something like that. I am confused by "one object in one .Rdata file"
Hadley's online book R Packages (and particularly the chapter on data) does a more thorough job of describing how to include data, but I'll walk through how to make arbitrary objects useful in a package.
Up front:
one has private data (accessible to same-package functions without change, accessible outside of the package using :::) and public data (data available to both internal functions and whomever loads the package, optionally lazy-loaded)
public data is stored in the ./mypackage/data/ directory, and it shall use the *.rda extension (*.Rdata) does not work; a common convention (for version-control, convenience, maintainability) though not a strict requirement is for one object per .rda file, and named as the object name; below, I stored mypubliclist in ./mypackage/data/mypubliclist.rda;
private data should all be saved in one file, ./mypackage/R/sysdata.rda.
Here's a sample package (I'm using devtools, but there are other ways to do so):
devtools::create("~/StackOverflow/14489611/mypackage")
# v Creating 'C:/Users/r2/StackOverflow/14489611/mypackage/'
# v Setting active project to 'C:/Users/r2/StackOverflow/14489611/mypackage'
# v Creating 'R/'
# v Writing 'DESCRIPTION'
# Package: mypackage
# Title: What the Package Does (One Line, Title Case)
# Version: 0.0.0.9000
# Authors#R (parsed):
# * First Last <first.last#example.com> [aut, cre] (YOUR-ORCID-ID)
# Description: What the package does (one paragraph).
# License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a
# license
# Encoding: UTF-8
# LazyData: true
# Roxygen: list(markdown = TRUE)
# RoxygenNote: 7.1.1
# v Writing 'NAMESPACE'
# v Changing working directory to 'C:/Users/r2/StackOverflow/14489611/mypackage/'
I wrote a small script ./data-raw/mylist.R to create some random data. This file is merely for reproducibility, it is not referenced during package production or loading.
set.seed(42) # R-4.0.2
myprivatelist <- list(a = sample.int(10), b = sample.int(1e5))
mypubliclist <- list(a=1:10, b=11:20)
save(mypubliclist, file="~/StackOverflow/14489611/mypackage/data/mypubliclist.rda")
save(myprivatelist, file="~/StackOverflow/14489611/mypackage/R/sysdata.rda")
I also created an R file ./mypackage/R/data.R (you can name this file anything, but it must be under ./mypackage/R) to contain simple documentation for these lists:
#' My private list
#' #format list with random numbers
"myprivatelist"
#' My public list
#' #format list with not-so-random numbers
"mypubliclist"
And now generate documentation:
devtools::document("C:/Users/r2/StackOverflow/14489611/mypackage")
# Updating mypackage documentation
# Loading mypackage
# Writing myprivatelist.Rd
# Writing mypubliclist.Rd
I'll build the package, restart R, install and then load the datasets.
devtools::build("~/StackOverflow/14489611/mypackage")
# v checking for file 'C:\Users\r2\StackOverflow\14489611\mypackage/DESCRIPTION'
# - preparing 'mypackage':
# v checking DESCRIPTION meta-information
# - checking for LF line-endings in source and make files and shell scripts
# - checking for empty or unneeded directories
# NB: this package now depends on R (>= 3.5.0)
# WARNING: Added dependency on R >= 3.5.0 because serialized objects in serialize/load version 3 cannot be read in older versions of R. File(s) containing such objects: 'mypackage/R/sysdata.rda' 'mypackage/data/mypubliclist.rda'
# - building 'mypackage_0.0.0.9000.tar.gz'
#
# [1] "C:/Users/r2/StackOverflow/14489611/mypackage_0.0.0.9000.tar.gz"
## restart R
install.packages("C:/Users/r2/StackOverflow/14489611/mypackage_0.0.0.9000.tar.gz")
# Installing package into 'C:/Users/r2/R/win-library/4.0'
# (as 'lib' is unspecified)
# inferring 'repos = NULL' from 'pkgs'
# * installing *source* package 'mypackage' ...
# ** using staged installation
# ** R
# ** data
# *** moving datasets to lazyload DB
# ** byte-compile and prepare package for lazy loading
# ** help
# *** installing help indices
# converting help for package 'mypackage'
# finding HTML links ... done
# myprivatelist html
# mypubliclist html
# ** building package indices
# ** testing if installed package can be loaded from temporary location
# *** arch - i386
# *** arch - x64
# ** testing if installed package can be loaded from final location
# *** arch - i386
# *** arch - x64
# ** testing if installed package keeps a record of temporary installation path
# * DONE (mypackage)
And let's see what worked:
str(mypubliclist)
# Error in str(mypubliclist) : object 'mypubliclist' not found
# x
# 1. \-utils::str(mypubliclist)
library(mypackage)
str(mypubliclist)
# List of 2
# $ a: int [1:10] 1 2 3 4 5 6 7 8 9 10
# $ b: int [1:10] 11 12 13 14 15 16 17 18 19 20
str(myprivatelist)
# Error in str(myprivatelist) : object 'myprivatelist' not found
# x
# 1. \-utils::str(myprivatelist)
str(mypackage:::myprivatelist)
# List of 2
# $ a: int [1:10] 1 5 10 8 2 4 6 9 7 3
# $ b: int [1:100000] 47128 16740 61605 73236 9091 62041 33700 59359 54789 54586 ...
And its documentation, if you're curious. (I use print because otherwise it'll pop up in the other pane; this just dumps it to the console.)
print(help("mypubliclist"))
# mypubliclist package:mypackage R Documentation
# My public list
# Description:
# My public list
# Usage:
# mypubliclist
#
# Format:
# list with not-so-random numbers
print(help("myprivatelist"))
# myprivatelist package:mypackage R Documentation
# My private list
# Description:
# My private list
# Usage:
# myprivatelist
#
# Format:
# list with random numbers
I am trying to use the mapdist function in ggmap package in R but I am getting the error Warning: Reverse geocoding failed with error: This API project is not authorized to use this API. below is my code
> p1
[1] -77.1365 38.8190
> p2
[1] -77.0625 38.8049
> mapdist(p1, p2, mode = "walking")
Warning: Reverse geocoding failed with error:
This API project is not authorized to use this API.
Warning: Reverse geocoding failed with error:
This API project is not authorized to use this API.
# A tibble: 1 x 3
from to mode
<chr> <chr> <chr>
1 NA NA walking
I have tested the codes below to test if I have correctly enabled all APIs in google console and it works
> (wh <- as.numeric(geocode("the white house, dc")))
Source : https://maps.googleapis.com/maps/api/geocode/json?address=the+white+house,+dc&key=xxx
[1] -77.03653 38.89768
> (lm <- as.numeric(geocode("lincoln memorial washington dc")))
Source : https://maps.googleapis.com/maps/api/geocode/json?address=lincoln+memorial+washington+dc&key=xxx
[1] -77.05018 38.88927
> mapdist(wh, lm, mode = "walking")
Any help is greatly appreciated. Thanks!
I am using decode_short_url of the twitteR package to decode shortened URLs from Twitter posts, but I am not able to get the desired results, It is always giving back the same results such as:
decode_short_url(decode_short_url("http://bit.ly/23226se656"))
## http://bit.ly/23226se656
## [1] "http://bit.ly/23226se656
UPDATE I wrapped this functionality in a package and managed to get it on CRAN same-day. Now, you can just do:
library(longurl)
expand_urls("http://bit.ly/23226se656", check=TRUE, warn=TRUE)
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Source: local data frame [1 x 2]
##
## orig_url expanded_url
## 1 http://bit.ly/23226se656 NA
##
## Warning message:
## In FUN(X[[i]], ...) : client error: (404) Not Found
You can pass in a vector of URLs and get a data_frame/data.frame back in that form.
That particular bit.ly URL gives a 404 error. Here's a version of decode_short_url that has an optional check parameter that will attempt a HEAD request and throw a warning message for any HTTP status other than 200.
You can further modify it to return NA in the event the "expanded" link 404's (I have no idea what you need this to really do in the event the link is bad).
NOTE that the addd HEAD request will significantly slow the process down, so you may want to do a first pass with check=FALSE to a separate column, then compare which weren't "expanded", then check those with check=TRUE.
You might also want to rename this to avoid namespace conflicts with the one from twitteR.
decode_short_url <- function(url, check=FALSE, ...) {
require(httr)
request_url <- paste("http://api.longurl.org/v2/expand?url=",
url, "&format=json", sep="")
response <- GET(request_url, query=list(useragent="twitteR"), ...)
parsed <- content(response, as="parsed")
ret <- NULL
if (!("long-url" %in% names(parsed))) {
ret <- url
} else {
ret <- parsed[["long-url"]]
}
if (check) warn_for_status(HEAD(url))
return(url)
}
decode_short_url("http://bit.ly/23226se656", check=TRUE)
## [1] "http://bit.ly/23226se656"
## Warning message:
## In decode_short_url("http://bit.ly/23226se656", check = TRUE) :
## client error: (404) Not Found
I am trying to access the Moz API with R to get some data but I cannot get the signed authentication right so my requests always get 401 response. I think something is wrong with the signature. Here is my code:
library(rjson)
library(digest)
library(RCurl)
# Construct the url to call the API
api <- 'http://lsapi.seomoz.com/linkscape/url-metrics/'
site <- 'facebook.com'
# that is the cols parameter that I need to get the data required
# there is no issue with it as it works when used with the provided sample call
metrics <- 'Cols=36029458443938976'
ampersand <- '&'
# this is my access id as given by Moz
access_id <- 'member-d8fc642751'
# this gets the current time and adds another 5 minutes as recommended (Unix timestamp format)
expires <- round(as.numeric(as.POSIXct(Sys.time()+300)))
# this concatenates the access id and the expires with a linefeed as explained in the API doc
hash_string <- paste('member-d8fc642751','\n', expires, sep="")
# this hashes the string from above with my secret key with sha1, don't worry this key is not valid anymore
hmac_hash <- hmac('f74fc2f2a8d5337aaa0550bfa3a9bdaf', hash_string, "sha1")
# Encoding with base64
base64_hash <- base64(hmac_hash)
# URL encoding the generated signature
encoded_signature <- URLencode(base64_hash, reserved = TRUE)
# constructing the url for the API call
url <- paste(api, site, '?', metrics, ampersand, 'AccessID=', access_id, ampersand, 'Expires=', expires, ampersand, 'Signature=', encoded_signature, sep="")
# Get data from API (json format)
Moz_json_data <- fromJSON(file=url, method='C')
Here is a comparison:
1. http://lsapi.seomoz.com/linkscape/url-metrics/facebook.com?Cols=36029458443938976&AccessID=member-d8fc642751&Expires=1415381495&Signature=YThmYTI1N2I4MDYzY2QxMGQzNDNjOWVlNmIyYTU1MzgzY2FlOWFiOA%3d%3d
2. http://lsapi.seomoz.com/linkscape/url-metrics/facebook.com?Cols=36029458443938976&AccessID=member-d8fc642751&Expires=1415465853&Signature=vyZmngnjiYy5Ns62LCLRHXgQQ6c%3D
The first one is generated by the code and does not work. The second one is provided as a sample request by Moz and works. As you can see the Signature in the second one much shorter, which makes me think I am generating the wrong signature but I do follow the same steps as outlined in their API doc.
Useful links:
http://apiwiki.moz.com/signed-authentication
http://apiwiki.moz.com/anatomy-of-a-mozscape-api-call
Any help will be greatly appreciated!
If you follow the example PHP code they provide, you'll see that they set raw=TRUE when calling hash_hmac. Thus when they encode the data, they are encoding the bytes of the hash, not the character representation of the bytes of the hash. You need to do this in the R version as well. Compare
# INCORRECT
(dd <- hmac('f74fc2f2a8d5337aaa0550bfa3a9bdaf', hash_string, "sha1"))
# [1] "e521bd74fba9296920efb897a2bc7578d3e8b075"
base64(dd)
# [1] "ZTUyMWJkNzRmYmE5Mjk2OTIwZWZiODk3YTJiYzc1NzhkM2U4YjA3NQ=="
# attr(,"class")
# [1] "base64"
and
# CORRECT
(dd <- hmac('f74fc2f2a8d5337aaa0550bfa3a9bdaf', hash_string, "sha1", raw=TRUE))
# [1] e5 21 bd 74 fb a9 29 69 20 ef b8 97 a2 bc 75 78 d3 e8 b0 75
base64(dd)
# [1] "5SG9dPupKWkg77iXorx1eNPosHU="
# attr(,"class")
# [1] "base64"