Send Authorization Request URL (script step reference)

Troi URL Plug-in > Script steps reference > Send Authorized Request URL
Troi URL Plug-in for FileMaker Pro

Send Authorized Request URL

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

SyntaxScript step badge

Send Authorized Request URL [ Select; Result ; Switches ; method ;
requestURL; accessToken ; accessTokenSecret ;
theRequest ]

Options

Select entire contentsreplaces the entire contents of a field with the result. If not checked the result replaces the currently selected portion of the field
Resultthe result of the request (or an error code)
switchesdetermine the behavior 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

you can also use this switch:

-ReturnDataAfterErrorreturn the error code followed by the data

Returned Result

Data type returned

text

Result

If successful this script step 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 5.0

Compatibility

FileMaker Pro 16

Considerations

With this script step 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 (or Send Authorization PIN URL script step).

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.
Send Authorized Request URL [ Select ; $Result ; "-OAuthProtocol" ; "POST" ; 
		$URL ; $oauth_token ; $oauth_token_secret ; $request ]
Set Field [ this::Received text ; $Result ]

Related functionFunction badge

TURL_SendAuthorizedRequest

Online Help Page for Troi URL Plug-in for 12 to 16 –> Send Authorized Request URL (urlp7416) 2017-0626 14:24:02