ForumsDevelopersToodledo API and Visual Basic


Toodledo API and Visual Basic
Author Message
Claudio

Posted: Aug 25, 2008
Score: 0 Reference
I'd like to transfer info between Toodledo and an activity tracking module that I've developed.

I've done some Visual Basic programming but I've never used REST or any web services. I've read the Toodledo Developer's API and it seems quite straightforward except for initiating the connection with the Toodledo server.

Is there some sample VB code that I can use as a starting point, perhaps something that includes wrappers for the API calls?

Thanks.
keef

Posted: Aug 30, 2008
Score: 0 Reference
Hi Claudio,

Sorry for the late response. Try this code
keef
------------------------------------------------

Imports System.Net
Imports System.IO

Public Class Web

Public Shared Function GetAPIResponse(ByVal url As String) As String

Dim result As String = String.Empty

Try
'TODO add proxy support here

Dim request As WebRequest = WebRequest.Create(url)

Using response As HttpWebResponse = request.GetResponse()

Using sr As StreamReader = New StreamReader(response.GetResponseStream())
result = sr.ReadToEnd()
End Using

End Using

Return result

Catch ex As Exception

Throw New Exception("Error requesting URL" & url, ex)

End Try

End Function

End Class
Claudio

Posted: Sep 02, 2008
Score: 0 Reference
Thanks keef.

Unfortunately, I don't understand how your code snippet fits into my sample application.

For now, I'm experimenting with a VB application that consists of one form with one button and one textbox, and I want to attach code to the button's click event that will add a Toodledo task with the name specified in the textbox.
(Later, I will add code that will get the task data from an SQL database.)

I would appreciate any help you can provide to get me started, including just pointing me in the right direction.

(Almost all of my VB experience is related to manipulating local and LAN-based data. I have practically no experience with Web-based applications or data.)

Thanks.
keef

Posted: Sep 03, 2008
Score: 0 Reference
Hi Claudio,

The Toodledo API is REST based, which means that all operations are performed using URL based commands.

You would use this code to send a URL command to the web site API and retrieve a response.

For example, the first operation you need to perform when using the API is to get a session token. This operation is performed using the following URL

http://www.toodledo.com/api.php?method=getToken;userid=<your id>

After adding the above code to your application, you would achieve this as follows

Dim request as String
Dim result as String
request="http://www.toodledo.com/api.php?method=getToken;userid=td47648ea0b4bc9"
result = Web.GetAPIResponse(request)

and result would contain the response from the web site

hope that helps

keef
Claudio

Posted: Sep 04, 2008
Score: 0 Reference
Thanks, keef.

The main issue was how to incorporate your sample code into a VB Form Application. Other issues were how to parse the session token and how to create a 32-character hash.

I've now figured out the basics.

Thanks again.
You cannot reply yet

U Back to topic home

R Post a reply

To participate in these forums, you must be signed in.