Raspberry BASIC

Author Topic: Working with cURL  (Read 167 times)

John Spikowski

  • Moderator
  • *****
  • Posts: 20
    • View Profile
    • ScriptBasic
Working with cURL
« on: April 15, 2019, 05:06:58 AM »
This thread will be about using ScriptBasic and the cURL extension module. The first example is what I call my Hello Me cURL example. This is also included in the extension module test scripts I posted in the Resources thread.

Code: Script BASIC
  1. ' MyIP
  2.  
  3. IMPORT curl.bas
  4.  
  5. ch = curl::init()
  6. curl::option(ch,"URL","ipinfo.io")
  7. PRINT curl::perform(ch),"\n"
  8.  
  9. curl::finish(ch)
  10.  

Output

pi@RPi3B:~/sbrpi/examples $ time scriba myip.sb
{
  "ip": "#4.#9.#1.#11",
  "hostname": "c-#4-#9-#1-#11.hsd1.wa.comcast.net",
  "city": "Anacortes",
  "region": "Washington",
  "country": "US",
  "loc": "48.5004,-122.6310",
  "postal": "98221",
  "org": "AS33650 Comcast Cable Communications, LLC"
}

real   0m0.334s
user   0m0.049s
sys   0m0.016s
pi@RPi3B:~/sbrpi/examples $


« Last Edit: April 15, 2019, 08:55:43 PM by John Spikowski »
ScriptBasic Project Manager/Facilitator