Changing from API v1.0 to v1.1, Status Updates Only, Need VB Example Please


#1

Hello there!

Sorry for what may be a silly question, but I have read through a bunch of the v1.1 API docs (focusing on this: https://dev.twitter.com/docs/api/1.1/post/statuses/update) yet I am still lost.

The only thing I am looking to do is update my status programmaticly. The given JSON example does not state which fields are optional and I have no idea how or where to stick it in the POST method (such as “JSON = …”)??

My previous code worked fine until a copy days ago. Step seven below is what I need to change, but struggling to do so…

v1.0 VB code **********************************************************

Sub send_message(TweetMsg As String, cOauth_consumer_key As String, _
cOauth_consumer_secret As String, cOauth_token As String, cOTS As String)

'STEP 1: build authentication
cApi_method = “POST” '
cApi_resource = “http://api.twitter.com/1/statuses/update.xml” ’ TO BE REPLAECE WITH "https://api.twitter.com/1.1/statuses/update.json"
cOauth_signature_method = "HMAC-SHA1"
cOauth_version = "1.0"
cStatus = URLEncode(TweetMsg)

'step 2: calculate nonce and timestamp
cOauth_nonce = get_oauth_nonce()
cOauth_timestamp = get_oauth_timestamp

'step 3: calculate base_string
cBase = get_basestring(cApi_method, cApi_resource, cOauth_consumer_key, cOauth_consumer_secret, cOauth_signature_method, cOauth_version, cOauth_token, cOTS, cOauth_nonce, cOauth_timestamp, cStatus)

'step 4: calculate composite signing key
cKey = cOauth_consumer_secret & “&” & cOTS

'step 5: calculate oauth_signature
cOauth_signature = get_oauth_signature(cBase, cKey)

'step 6: calcualte authorization header
cHeader = get_header(cApi_resource, cOauth_nonce, cOauth_signature_method, cOauth_timestamp, cOauth_consumer_key, cOauth_token, cOauth_signature, cOauth_version)

'******************* THIS IS WHAT I NEED HELP WITH *********************
'step 7: send message

Set xml = CreateObject("MSXML2.XMLHTTP")
xml.Open cApi_method, cApi_resource & "?status=" & cStatus, False
xml.setRequestHeader "Authorization", cHeader
xml.Send
tResult = xml.responseText
Debug.Print tResult
Set xml = Nothing

End Sub

end of v1.0 VB Code ***********************************************

I have tried changing step 7 to use the .Navigate2 method of the MS IE control and the WebBrowser1 control (with the new URL) but keep getting errors about being “unable to download the URL”. I’m not sure how to pass the JSON in the POST method, or given the fact that I am only send a status update, do I simply send something like “status=Maybe%20he%27ll%20finally%20find%20his%20keys.%20%23peterfalk” in the POST and not even worry about JSON? In other words, why do I need JSON when the example shows POST Data that is not in JSON format? Sorry, I’m just confused.

Any examples or direction would be greatly appreciated.

Thanks so much for your help!

Trip


#2

In my app, PHP, I just changed “https://api.twitter.com/1/” to “https://api.twitter.com/1.1/”.

I hope this helps.


#3

I’ll give it a shot! Thanks! :slight_smile:


#4

I just changed “https://api.twitter.com/1/” to “https://api.twitter.com/1.1/”.

Worked for me! THANKS!