Groovy Script: Send a Tweet with Location

    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"