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:
11.0
11.1
11.2
11.3
11.4
11.5
12.0
12.1
12.2
12.3
Statistic
FMM
Blog
CURL.New
Start a new CURL easy session.
Component | Version | macOS | Windows | Linux | Server | iOS SDK | License |
CURL | 2.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | Free |
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 in Background
- CURL/CURL Download Text
- CURL/CURL Download to Container
- CURL/CURL Send Form
- CURL/Email/Email Parser and Preview
- CURL/Email/List IMAP folders
- 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
- 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
- Query geolocation in FileMaker via MBS Plugin and Google Maps API
- Batch sending Emails in FileMaker via MBS Plugin
FileMaker Magazin
Created 18th August 2014, last changed 19th April 2020
CURL.LoadLibrary - CURL.NumberOfRunningTransfers
Feedback: Report problem or ask question.
