Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
CURL.New
Start a new CURL easy session.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
CURL | 2.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
none
Result
A new CURL handle.
Description
Start a new CURL easy session.This function must be the first function to call, and it returns a CURL handle that you must use as input to other CURL functions. CURL.New initializes curl and this call MUST have a corresponding call to CURL.Release when the operation is complete. You can use one curl object for multiple transfers reusing same connection.
Result is a number greater than zero on success. Errors returned may be about low memory or two many CURL connections.
CURL reference numbers are starting at 16000 and counting up for each new session.
Examples
Initialize a CURL session and set URL:
$curl = MBS( "CURL.New" )
$r = MBS("CURL.SetOptionURL"; $curl; $URL)
Query a REST API:
# new session
Set Variable [$curl; MBS( "CURL.New" ) ] ]
# set URL for this REST API
Set Variable [$r; MBS("CURL.SetOptionURL"; $curl; "https://example.test/wc-api/v2/products") ]
# make a post with some data
Set Variable [$r; MBS("CURL.SetOptionPost"; $curl; 1) ]
Set Variable [$r; MBS("CURL.SetOptionPostFields"; $curl; "{product:{...}}"; "UTF-8") ]
# set credentials
Set Variable [$r; MBS("CURL.SetOptionUserName"; $curl; "consumer_key") ]
Set Variable [$r; MBS("CURL.SetOptionPassword"; $curl; "consumer_secret") ]
# add header option
Set Variable [$r; MBS("CURL.SetOptionHTTPHeader"; $curl; "Content-Type: application/json", "Expect:" ) ]
# disable security for this demo:
Set Variable [$r; MBS( "CURL.SetOptionSSLVerifyHost"; $curl; 0 ) ]
Set Variable [$r; MBS( "CURL.SetOptionSSLVerifyPeer"; $curl; 0 ) ]
# with log messages
Set Variable [$r; MBS( "CURL.SetOptionVerbose"; $curl; 1 ) ]
# run it!
Set Variable [$Error; MBS( "CURL.Perform"; $curl ) ]
# check debug messages
Set Variable [$Messages; MBS("CURL.GetDebugMessages"; $curl) ]
# check result
Set Variable [$Output; MBS("CURL.GetResultAsText"; $curl) ]
# and cleanup
Set Variable [$r; MBS( "CURL.Release"; $curl ) ]
Download a text from URL:
# start new transfer
Set Variable [$curl; Value:MBS("CURL.New")]
# set URL
Set Variable [$r; Value:MBS("CURL.SetOptionURL"; $curl; "https://www.mbsplugins.eu/")]
# run transfer
Set Variable [$ErrorCode; Value:MBS("CURL.Perform"; $curl)]
# get result as text and debug messages:
Set Variable [$TextResult; Value:MBS( "CURL.GetResultAsText"; $curl)]
Set Variable [$DebugMessages; Value:MBS( "CURL.GetDebugMessages"; $curl)]
# cleanup
Set Variable [$r; Value:MBS("CURL.Release"; $curl)]
See also
- CURL.SetOptionWildCardMatch
- CURL.SetSSLBackend
- CURL.SetTag
- CURL.SetupAWS
- CURL.UseSystemCertificates
- CURL.WebSocketSend
- Hash.Digest
- JSON.GetPathItem
- JSON.Parse
- Plugin.SetFunctions
Example Databases
- CURL/CURL Check FileMaker Server
- CURL/CURL Download on Server
- CURL/CURL Download to Container
- CURL/Email/Build and send Email
- CURL/Email/List IMAP folders
- CURL/FTP/CURL FTP Upload File
- CURL/WebServices/Swiss Post Addresscheck
- CURL/WebServices/TinyURL
- CURL/WebServices/Twilio API Send SMS Json
- CURL/WebServices/WeatherBit.io test
Blog Entries
- Send SMS with Amazon web service
- MBS FileMaker Advent calendar - Door 12 - Sending Mails
- Using ChatGPT in FileMaker
- Adding ChatGPT to the ScriptWorkspace context menu
- MQTT in FileMaker
- Background Log Custom function
- MBS Plugin Advent calendar: 21 - SendMail
- Parallel network transfers with MBS Plugin
- Send Audit Log via CURL in background
- How long do you wait for Insert From URL to finish?
FileMaker Magazin
This function checks for a license.
Created 18th August 2014, last changed 19th April 2020
