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.SetOptionVerbose
- CURL.SetProgressScript
- CURL.SetTag
- CURL.SetupAWS
- CURL.UseSystemCertificates
- CURL.WebSocketSend
- Hash.Digest
- JSON.GetPathItem
- JSON.Parse
- Plugin.SetFunctions
Example Databases
- CURL/Amazon S3/Amazon S3 Download Picture
- CURL/Amazon S3/Amazon S3 Upload File
- CURL/Amazon S3/Amazon S3 Upload Picture
- CURL/CURL Custom Function
- CURL/CURL Send Form
- CURL/Email/Build and send Email
- CURL/FTP/CURL FTP Upload from file with Progress
- CURL/WebServices/CURL FMS Admin API v18
- CURL/WebServices/Sales Force Test
- CURL/WebViewer Download Images with CURL
Blog Entries
- How long do you wait for Insert From URL to finish?
- SFTP Upload with temporary file
- CURL Custom Function
- Trigger Scripts via WebHook
- SMTP with OAuth for Office 365 in FileMaker
- Sending email with a huge custom function
- Use Inline Graphics in Emails
- Translating Insert from URL options for CURL to MBS Plugin calls
- Using Apple's Global Service Exchange web service in FileMaker
- Let CURL handle cookie list
FileMaker Magazin
This function checks for a license.
Created 18th August 2014, last changed 19th April 2020
