Sample code for 30+ languages & platforms
PowerBuilder

Twitter OAuth -- Tweet to Your Own Account

See more HTTP Examples

Demonstrates how to send a tweet (status update) to your own Twitter account using pre-known credentials, which includes:

  1. Consumer Key
  2. Consumer Secret
  3. Access Token
  4. Token Secret

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Http
oleobject loo_Req
oleobject loo_Resp

li_Success = 0

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Http.OAuth1 = 1
loo_Http.OAuthVerifier = ""
loo_Http.OAuthConsumerKey = "my-consumer-key"
loo_Http.OAuthConsumerSecret = "my-consumer-secret"
loo_Http.OAuthToken = "my-access-token"
loo_Http.OAuthTokenSecret = "my-token-secret"

// Send the same status update as shown in this example:
// https://dev.twitter.com/docs/api/1.1/post/statuses/update

// IMPORTANT: Make sure this app has read/write access.  
// Otherwise it cannot post an update (i.e. tweet) to the Twitter account.

loo_Req = create oleobject
li_rc = loo_Req.ConnectToNewObject("Chilkat.HttpRequest")

loo_Req.AddParam("status","Maybe he'll finally find his keys. #peterfalk")

loo_Req.HttpVerb = "POST"
loo_Req.ContentType = "application/x-www-form-urlencoded"

loo_Resp = create oleobject
li_rc = loo_Resp.ConnectToNewObject("Chilkat.HttpResponse")

li_Success = loo_Http.HttpReq("https://api.twitter.com/1.1/statuses/update.json",loo_Req,loo_Resp)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_Req
    destroy loo_Resp
    return
end if

if loo_Resp.StatusCode = 200 then
    // Display the JSON response.
    Write-Debug loo_Resp.BodyStr
else
    Write-Debug loo_Http.LastErrorText
end if



destroy loo_Http
destroy loo_Req
destroy loo_Resp