Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Groovy Script: Send a Tweet with Location

No ratings

This Groovy script is called from an Expression Rule of type Location. For example, in an Expression rule

ExecuteCustomObject("SendTweetWithLocation","user","password","Asset is on the move")


calls the script "SendTweetWithLocation" with the parameters in order. The twitterStatus is the text to send to twitter. Use the user/password for an actual twitter account.  Also, the script uses the implicit objects context and mobileLocation.


Variable Name      Display Name
twitterUser                twitterUser
twitterPassword      twitterPassword
twitterStatus            twitterStatus


import static*

import com.axeda.drm.sdk.geofence.Geofence

twitter = new RESTClient('')

twitter.auth.basic parameters.twitterUser, parameters.twitterPassword

twitter.client.params.setBooleanParameter 'http.protocol.expect-continue', false

def statusText = "'${parameters.twitterStatus}' for device: ${context.device.serialNumber} on ${new Date()}"

resp = 'update.xml',

        requestContentType: URLENC,

        body: [status: statusText, lat:, long: mobileLocation.lng]) resp.status "Posted update $statusText"

Version history
Last update:
‎May 26, 2016 05:52 PM
Updated by:
Labels (2)