TURL_SendAuthorizedRequest (function reference)

By June 1, 2017 September 26th, 2017 Online Help, Troi URL plug-in
Troi URL Plug-in > Functions reference > TURL_SendAuthorizedRequest
Troi URL Plug-in for FileMaker Pro

TURL_SendAuthorizedRequest

Sends a request (like posting a tweet), using the 2 credentials obtained during authorization.

SyntaxFunction badge

TURL_SendAuthorizedRequest ( switches ; method ; requestURL; accessToken ;
accessTokenSecret ; theRequest )

Parameters

switchesdetermine the behaviour of the function
methodeither POST or GET
requestURLURL of the web service to where the request must be sent
accessTokenpart 1 of the 2 credentials obtained during authorization
accessTokenSecretpart 2 of the 2 credentials obtained during authorization
theRequestthe request you want to perform

Switches

switches must be set to:

-OAuthProtocolthe plug-in is using the OAuth protocol

Returned Result

Data type returned

text

Result

If successful this function returns the result of the request. If unsuccessful it returns an error code starting with $$ followed by the error code.

Originated in

Troi URL Plug-in 2.6

Compatibility

FileMaker Pro 12 to 16

Considerations

With this function you can perform the actual work by sending requests to the web service, for example post a tweet on Twitter.
You need to have gotten credentials first with the two authorization functions TURL_GetAuthorizationURL and TURL_SendAuthorizationPIN.

The plug-in currently only supports the OAuth 1.0A Authorization protocol.

Example

# This script will post a tweet on Twitter. 
# Get the text to tweet in a variable:
Set Variable [ $TweetText ; this::TweetText ]
# Set up the other variables:
Set Variable [ $URL ; "http://api.twitter.com/1/statuses/update.json" ]
# Use the credentials stored in two global fields:
Set Variable [ $oauth_token ; this::gOAuth_token ]
Set Variable [ $oauth_token_secret ; this::gOAuth_token_secret ]
# Build the request to tweet (= a status update in the API):
# NOTE: the text of the tweet must be URL Encoded.
Set Variable [ $request ; "status=" & TURL_ToURLEncoded ( "-Unused" ; this::TweetText ) ]
#
# Now send the tweet to Twitter, using the POST method, and the oauth credentials.
Set Variable [ $Result ; TURL_SendAuthorizedRequest ( "-OAuthProtocol:" ; "POST" ; 
		$URL ; $oauth_token ; $oauth_token_secret ; $request ) ]
Set Field [ this::Received text ; $Result ]

Related functionsFunction badge

TURL_GetAuthorizationURL
TURL_SendAuthorizationPIN
TURL_SetAuthCredentials

Online Help Page for Troi URL Plug-in for 12 to 16 –> TURL_SendAuthorizedRequest (urlp4416) 2017-0623 12:53:22