Learn R Programming

whapi (version 0.0.2)

whapi_send_location: Send a geographic location via Whapi.Cloud

Description

Sends a location message using Whapi's POST /messages/location. Supports optional name (short title) and address (human-readable).

Usage

whapi_send_location(
  to,
  latitude,
  longitude,
  name = NULL,
  address = NULL,
  token = Sys.getenv("WHAPI_TOKEN", unset = ""),
  timeout = 30,
  verbose = TRUE
)

Value

A tibble with id, to, status, timestamp, timestamp_dt, and raw resp.

Arguments

to

Character(1). WhatsApp target (E.164 digits only, no "+") or chat id.

latitude

Numeric(1). Latitude in decimal degrees (range: -90..90).

longitude

Numeric(1). Longitude in decimal degrees (range: -180..180).

name

Optional character(1). Short title for the location.

address

Optional character(1). Human-readable address/description.

token

Bearer token (defaults to env var WHAPI_TOKEN).

timeout

Numeric. Request timeout (seconds). Default 30.

verbose

Logical. Print CLI messages? Default TRUE.

Examples

Run this code
if (FALSE) {
 Sys.setenv(WHAPI_TOKEN = "your_token_here")
 whapi_send_location("5581999999999",
   latitude = -8.063169, longitude = -34.871139,
   name = "Marco Zero", address = "Recife, PE")

# Group id example
 whapi_send_location("1203630xxxxxxxx@g.us", -8.045, -34.91)
}

Run the code above in your browser using DataLab