Skip to main content

TURL_SendAuthorizedRequest (function reference)

By October 1, 2021October 13th, 2021Online 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

switches determine the behaviour of the function
method either POST or GET
requestURL URL of the web service to where the request must be sent
accessToken part 1 of the 2 credentials obtained during authorization
accessTokenSecret part 2 of the 2 credentials obtained during authorization
theRequest the request you want to perform

Switches

switches must be set to:

-OAuthProtocol the 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 16 to 19

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

Related topics

Troi URL Plug-in online help (overview)


Online Help Page for Troi URL Plug-in for 16 to 19 –> TURL_SendAuthorizedRequest (urlp4416) 2021-1013 16:32:55