Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides
New in version: 5.4   6.0   6.1   6.2   6.3   6.4   6.5   7.0   7.1   7.2    Statistic  

CURL.GetResultAsText

Returns the result of the transaction as text.

Component: CURL
Version: 2.5
Mac OS X: Yes
Windows: Yes
Server: Yes
FileMaker Cloud: Yes

MBS( "CURL.GetResultAsText"; Handle { ; Encoding } )

Parameters

Parameter Description Example value
Handle The CURL session handle. $curl
Encoding Optional
The text encoding for result.
Default is native. This function can also handle UTF-16 as well as UTF-16LE and UTF-16BE for little/big endian byte order.
Possible encoding names: ANSI, Arabic-Mac, Arabic-Win, Baltic-Win, CentralEurope-Mac, ChineseSimp-Mac, ChineseSimp-Win, ChineseTrad-Mac, ChineseTrad-Win, Cyrillic-Mac, Cyrillic-Win, EasternEurope-Win, Greek-Mac, Greek-Win, Hebrew-Mac, Hebrew-Win, ISO-8859-1, ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-8859-15, Korean-Johab, Korean-Mac, Korean-Win, Latin1, Mac, Native, ShiftJIS-Mac, ShiftJIS-Win, Turkish-Mac, Turkish-Win, UTF-8, DOS or Windows. Pass native to use the native encoding of the current platform.
"UTF-8"

Result

The result as text.

Description

Returns the result of the transaction as text.
You are responsible for detecting decoding.

See also CURL.GetResultAsContainer.

Plugin version 5.2 and newer replace newlines automatically for you to match what FileMaker uses (Mac line endings).

Examples

Query result as UTF-8 text:

MBS("CURL.GetResultAsText"; $curl; "UTF-8")

Query result as Windows Ansi encoding:

MBS("CURL.GetResultAsText"; $curl; "windows")

Get result text and convert line endings for FileMaker:

MBS("Text.ReplaceNewline"; MBS("CURL.GetResultAsText"; $curl);1)

Download some text:

Set Variable [$curl; Value:MBS("CURL.New")]
Set Variable [$result; Value:MBS("CURL.SetOptionURL"; $curl; CURL Test::URL)]
Set Field [CURL Test::Result; MBS("CURL.Perform"; $curl)]
Set Field [CURL Test::Text; MBS("CURL.GetResultAsText"; $curl; "UTF8")]
Set Variable [$result; Value:MBS("CURL.Cleanup"; $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.Cleanup"; $curl)]

Query webservice with JSON request:

Set Variable [$curl; Value:MBS("CURL.New")]
Set Variable [$result; Value:MBS("CURL.SetOptionURL"; $curl; "http://test.test/ws/v1/catalogo/getmodelos")]
#pass JSON for query
Set Variable [$result; Value:MBS("CURL.SetOptionPostFields"; $curl; "{\"brandId\" : \"1\", \"device\" : \"70\"}"; "UTF-8")]
Set Field [models::result; MBS("CURL.Perform"; $curl)]
Set Field [models::text; MBS("CURL.GetResultAsText"; $curl;"UTF8")]
Set Field [models::header; MBS("CURL.GetDebugAsText"; $curl)]
Set Variable [$result; Value:MBS("CURL.Cleanup"; $curl)]

See also


CURL.GetResultAsPNG   -   CURL.GetResultLength

Feedback: Report problem or ask question.




Links
MBS REALbasic Plugins - Pfarrgemeinde St. Arnulf Nickenich