Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
9.3
9.4
9.5
10.0
10.1
10.2
10.3
10.4
10.5
11.0
Statistic
FMM
Blog
CURL.New
Start a new CURL easy session.
Component | Version | macOS | Windows | Linux | Server | FileMaker 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.GetDebugAsText"; $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.GetDebugAsText"; $curl)]
# cleanup
Set Variable [$r; Value:MBS("CURL.Release"; $curl)]
See also
- CURL.SetOptionUserName
- CURL.SetOptionWildCardMatch
- CURL.SetProgressScript
- CURL.SetTag
- CURL.SetupOAuth
- CURL.UseSystemCertificates
- Hash.Digest
- JSON.GetPathItem
- JSON.Parse
- Plugin.SetFunctions
Example Databases
- CURL/Amazon S3 Download Picture
- CURL/CURL Download on Server
- CURL/CURL Download to Container
- CURL/CURL Download with Progress
- CURL/CURL with certificates included with FileMaker
- CURL/Email/IMAP Email List
- CURL/FTP/CURL FTP Delete File
- CURL/WebServices/magento older
- CURL/WebServices/VAT WebService Example/VAT WebService Example
- Third Party/Google OAUTH 2 example
Blog Entries
- 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
- Use root certificates included with FileMaker
- URLs without UserName and Password please
- Email Script for FileMaker
- LogicalDOC Webservice
- Upload email to Sent folder via IMAP
- Amazon S3 Upload with Mime Type and Permissions
- Using Apple's Global Service Exchange web service in FileMaker
FileMaker Magazin
- Ausgabe 4/2016, Seite 20, PDF
- Ausgabe 4/2016, Seite 19, PDF
- Ausgabe 4/2016, Seite 18, PDF
- Ausgabe 5/2014, Seite 26, PDF
Created 18th August 2014, last changed 19th April 2020
CURL.LoadLibrary - CURL.NumberOfRunningTransfers
Feedback: Report problem or ask question.

Links
MBS FileMaker Plugins