Delicious API methods

delicious logo

In a previous post, I mentioned that Delicious (a Yahoo! company) is changing their API to use YQL, a query language based on SQL. So I'm stopping development on any delicious-related code and posting it here for reference only.

After delicious switches to YQL some time after June, this code will probably stop working. Consider this post a code dump of (soon to be) unsupported code.

Note that this isn't all of the available methods, only the ones I completed code for before learning of the switch to YQL, but it does cover most of the useful methods.

You'll also need to grab the helper functions and paste them into a standard module in the same project, and also the URLEncode Function found at Free VB Code.

Please call the delicious API methods sparingly, and read the API documentation for suggestions on how often to use various methods. Before calling any method that returns bookmarks, use the GetLastPostsUpdate Function to see if you need to call the function at all.

For reference: Delicious API

Find out when the last update occurred

This function "returns the last update time for the user, as well as the number of new items in the user's inbox since it was last visited." (from Delicious API)

Function GetLastPostsUpdate(userid As String, password As String) As String()

Dim xml As Object ' MSXML2.XMLHTTP
Dim result As String
Dim tempFile As String
Dim tempString() As String
Dim xmlDoc As Object ' MSXML2.DOMDocument
Dim update As Object ' MSXML2.IXMLDOMNode

  tempFile = environ("temp") & "\deliciouslastpostsupdate.xml"

  Set xml = CreateObject("MSXML2.XMLHTTP.6.0")

  xml.Open "GET", "https://" & userid & ":" & password & "@api.del.icio.us/v1/posts/update", False
  xml.Send

  result = xml.responseText

  ' create XML file from result
  Call CreateFile(tempFile, result)

  ' create XML doc
  Set xmlDoc = CreateObject("MSXML2.DOMDocument")

  With xmlDoc
    .async = False
    .validateOnParse = False
    .Load tempFile
  End With

  ' check that the XML doc loaded
  If LoadError(xmlDoc) Then
    Exit Function
  End If

  ' get first level nodes
  Set update = xmlDoc.childNodes(1)

  ' resize array
  ReDim tempString(1 To 2)

  tempString(1) = update.Attributes.getNamedItem("time").nodeTypedValue
  tempString(2) = update.Attributes.getNamedItem("inboxnew").nodeTypedValue

  GetLastPostsUpdate = tempString

End Function

Sample usage

Sub TestDelicious()

Dim lastPostUpdateTime() As String
Dim userid As String
Dim password As String

  userid = "some user id"
  password = "some password"

  lastPostUpdateTime = GetLastPostsUpdate(userid, password)
  Debug.Print lastPostUpdateTime(1)
  Debug.Print lastPostUpdateTime(2)
End Sub

Add new bookmark

This function will add a new bookmark to the specified user's account. You must provide the following pieces of information:

  • The userid and password of the account
  • The (url encoded) URL of the bookmark you want to add
  • The (url encoded) description of the URL

The following items are optional:

  • Notes for the item (an extended description)
  • A (url encoded) list of tags for the URL (space delimited)
  • A datestamp (see Add Posts for a description of how to pass the date)
  • Boolean variable indicating if the bookmark should replace an existing one (if it already exists)
  • Boolean variable indicating if the bookmark should be private (True = public, False = Private)
Function AddPost(userid As String, pwd As String, url As String, _
                 description As String, Optional notes As String, Optional tags As String, _
                 Optional datestamp As String, Optional replaceURL As Boolean = False, _
                 Optional sharedbookmark As Boolean = True) As Boolean

Dim xml As Object ' MSXML2.XMLHTTP
Dim result As String
Dim tempFile As String
Dim tempString() As String
Dim xmlDoc As Object ' MSXML2.DOMDocument
Dim xmlDocRoot As Object ' MSXML2.IXMLDOMNode
Dim resultCode As Object ' MSXML2.IXMLDOMNode
Dim toReplace As String
Dim toShare As String

  toReplace = Choose(replaceURL, "no", "yes")
  toShare = Choose(sharedbookmark, "no","yes")

  tempFile = environ("temp") & "\deliciousaddpost.xml"

  Set xml = CreateObject("MSXML2.XMLHTTP.6.0")

  xml.Open "GET", "https://" & userid & ":" & pwd & "@api.del.icio.us/v1/posts/add?" & _
                  "url=" & URLEncode(url) & "&description=" & URLEncode(description) & "&extended=" & _
                  URLEncode(notes) & "&tags=" & URLEncode(tags) & "&dt=" & datestamp & "&replace=" & _
                  toReplace & "&shared=" & toShare, False
  xml.Send

  result = xml.responseText

  ' create XML file from result
  Call CreateFile(tempFile, result)

  ' create XML doc
  Set xmlDoc = CreateObject("MSXML2.DOMDocument")

  With xmlDoc
    .async = False
    .validateOnParse = False
    .Load tempFile
  End With

  ' check that the XML doc loaded
  If LoadError(xmlDoc) Then
    Exit Function
  End If

  ' get first level nodes
  Set resultCode = xmlDoc.childNodes(1)

  AddPost = (resultCode.Attributes.getNamedItem("code").nodeTypedValue = "done")

End Function

Sample usage

In this example, I want to add the URL for the URLEncode Function as a delicious bookmark. As a description for the bookmark I want "URL Encode for VBA" and the tags should be "VBA" and "URLEncode".

Sub TestDelicious()

Dim userid As String
Dim password As String
Dim URL As String

  userid = "some user id"
  password = "some password"
  URL = "http://www.freevbcode.com/ShowCode.Asp?ID=5137"

  Debug.Print AddPost(userid, password, URL, "URL Encode for VBA", , "VBA URLEncode")
End Sub

Delete a bookmark

Deleting a post is as simple as calling the correct method with the URL of the bookmark you want to remove.

Function DeletePost(userid As String, pwd As String, url As String) As Boolean

Dim xml As Object ' MSXML2.XMLHTTP
Dim result As String
Dim tempFile As String
Dim tempString() As String
Dim xmlDoc As Object ' MSXML2.DOMDocument
Dim xmlDocRoot As Object ' MSXML2.IXMLDOMNode
Dim resultCode As Object ' MSXML2.IXMLDOMNode

  tempFile = environ("temp") & "\deliciousdeletepost.xml"

  Set xml = CreateObject("MSXML2.XMLHTTP.6.0")

  xml.Open "GET", "https://" & userid & ":" & pwd & _
                  "@api.del.icio.us/v1/posts/delete?" & "url=" & _
                  URLEncode(url), False
  xml.Send

  result = xml.responseText

  ' create XML file from result
  Call CreateFile(tempFile, result)

  ' create XML doc
  Set xmlDoc = CreateObject("MSXML2.DOMDocument")

  With xmlDoc
    .async = False
    .validateOnParse = False
    .Load tempFile
  End With

  ' check that the XML doc loaded
  If LoadError(xmlDoc) Then
    Exit Function
  End If

  ' get first level nodes
  Set resultCode = xmlDoc.childNodes(1)

  DeletePost = (resultCode.Attributes.getNamedItem("code").nodeTypedValue = "done")

End Function

Sample usage

I change my mind — I want to get rid of that bookmark I just added.

Sub TestDelicious()

Dim userid As String
Dim password As String
Dim URL As String

  userid = "some user id"
  password = "some password"
  URL = "http://www.freevbcode.com/ShowCode.Asp?ID=5137"

  Debug.Print DeletePost(userid, password, URL)
End Sub

Get bookmarks from a given day

Returns one or more posts on a single day matching the arguments. If no date or url is given, most recent date will be used. (from Delicious API)

The arguments are similar to those used with the AddPost function.

Function GetPostsByDate(userid As String, pwd As String, Optional tags As String, _
                        Optional datestamp As String, Optional url As String, _
                        Optional hashes As String, Optional meta As Boolean = True) As String()

Dim xml As Object ' MSXML2.XMLHTTP
Dim result As String
Dim tempFile As String
Dim tempString() As String
Dim xmlDoc As Object ' MSXML2.DOMDocument
Dim xmlDocRoot As Object ' MSXML2.IXMLDOMNode
Dim posts As Object ' MSXML2.IXMLDOMNodeList
Dim post As Object ' MSXML2.IXMLDOMNode
Dim i As Long

  tempFile = environ("temp") & "\deliciouspostsbydate.xml"

  Set xml = CreateObject("MSXML2.XMLHTTP.6.0")

  xml.Open "GET", "https://" & userid & ":" & pwd & _
                  "@api.del.icio.us/v1/posts/get?" & "tag=" & _
                  URLEncode(tags) & "&dt=" & datestamp & _
                  "&url=" & URLEncode(url) & "&hashes=" & URLEncode(hashes) & _
                  "&meta=" & meta, False
  xml.Send

  result = xml.responseText

  ' create XML file from result
  Call CreateFile(tempFile, result)

  ' create XML doc
  Set xmlDoc = CreateObject("MSXML2.DOMDocument")

  With xmlDoc
    .async = False
    .validateOnParse = False
    .Load tempFile
  End With

  ' check that the XML doc loaded
  If LoadError(xmlDoc) Then
    Exit Function
  End If

  ' get first level nodes
  Set xmlDocRoot = GetRootNode(xmlDoc)
  Set posts = GetChildNodes(xmlDocRoot)

  ' resize array
  ReDim tempString(1 To posts.Length, 1 To 7)

  For i = 1 To posts.Length

    Set post = posts.item(i - 1)

    tempString(i, 1) = post.Attributes.getNamedItem("href").nodeTypedValue
    tempString(i, 2) = post.Attributes.getNamedItem("description").nodeTypedValue
    tempString(i, 3) = post.Attributes.getNamedItem("extended").nodeTypedValue
    tempString(i, 4) = post.Attributes.getNamedItem("hash").nodeTypedValue
    tempString(i, 5) = post.Attributes.getNamedItem("meta").nodeTypedValue
    tempString(i, 6) = post.Attributes.getNamedItem("tag").nodeTypedValue
    tempString(i, 7) = post.Attributes.getNamedItem("time").nodeTypedValue
  Next i

  GetPostsByDate = tempString

End Function

Sample usage

Sub TestDelicious()

Dim tempString() As String
Dim userid As String
Dim password As String
Dim i As Long, j As Long

  userid = "some user id"
  password = "some password"

  tempString = GetPostsByDate(userid, password, , , , , True)
  For i = 1 To UBound(tempString)
    For j = 1 To UBound(tempString, 2)
      Debug.Print tempString(i, j)
    Next j
  Next i
End Sub

Return recently added bookmarks

This function returns a list of bookmarks, up to 100, optionally filtered by a single tag.

Function GetRecentPosts(userid As String, pwd As String, Optional tags As String, _
                        Optional numberOfResults As Long = 15, _
                        Optional forceRefresh As Boolean = False) As String()

Dim xml As Object ' MSXML2.XMLHTTP
Dim result As String
Dim tempFile As String
Dim tempString() As String
Dim xmlDoc As Object ' MSXML2.DOMDocument
Dim xmlDocRoot As Object ' MSXML2.IXMLDOMNode
Dim posts As Object ' MSXML2.IXMLDOMNodeList
Dim post As Object ' MSXML2.IXMLDOMNode
Dim i As Long

  tempFile = environ("temp") & "\deliciousrecentposts.xml"

  If Len(Dir(tempFile)) = 0 Or forceRefresh Then

    Set xml = CreateObject("MSXML2.XMLHTTP.6.0")

    xml.Open "GET", "https://" & userid & ":" & pwd & _
                    "@api.del.icio.us/v1/posts/recent?" & "tag=" & _
                    URLEncode(tags) & "&count=" & numberOfResults, False
    xml.Send

    result = xml.responseText

    ' create XML file from result
    Call CreateFile(tempFile, result)

  End If

  ' create XML doc
  Set xmlDoc = CreateObject("MSXML2.DOMDocument")

  With xmlDoc
    .async = False
    .validateOnParse = False
    .Load tempFile
  End With

  ' check that the XML doc loaded
  If LoadError(xmlDoc) Then
    Exit Function
  End If

  ' get first level nodes
  Set xmlDocRoot = GetRootNode(xmlDoc)
  Set posts = GetChildNodes(xmlDocRoot)

  ' resize array
  ReDim tempString(1 To posts.Length, 1 To 6)

  For i = 1 To posts.Length

    Set post = posts.item(i - 1)

    tempString(i, 1) = post.Attributes.getNamedItem("href").nodeTypedValue
    tempString(i, 2) = post.Attributes.getNamedItem("description").nodeTypedValue
    tempString(i, 3) = post.Attributes.getNamedItem("extended").nodeTypedValue
    tempString(i, 4) = post.Attributes.getNamedItem("hash").nodeTypedValue
    tempString(i, 5) = post.Attributes.getNamedItem("tag").nodeTypedValue
    tempString(i, 6) = post.Attributes.getNamedItem("time").nodeTypedValue
  Next i

  GetRecentPosts = tempString

End Function

Sample usage

This will return the last fifteen bookmarks for a given user.

Sub TestDelicious()

Dim tempString() As String
Dim userid As String
Dim password As String
Dim i As Long, j As Long

  userid = "some user id"
  password = "some password"

  tempString = GetRecentPosts(userid, password)
  For i = 1 To UBound(tempString)
    For j = 1 To UBound(tempString, 2)
      Debug.Print tempString(i, j)
    Next j
  Next i
End Sub

Get bookmark dates

You can retrieve the dates that bookmarks were added to a user account using this function. Optionally, you can filter the result by tag.

Function GetPostDates(userid As String, pwd As String, Optional tag As String) As String()

Dim xml As Object ' MSXML2.XMLHTTP
Dim result As String
Dim tempFile As String
Dim tempString() As String
Dim xmlDoc As Object ' MSXML2.DOMDocument
Dim xmlDocRoot As Object ' MSXML2.IXMLDOMNode
Dim dateNodes As Object ' MSXML2.IXMLDOMNodeList
Dim dateNode As Object ' MSXML2.IXMLDOMNode
Dim i As Long

  tempFile = environ("temp") & "\deliciouspostdates.xml"

  Set xml = CreateObject("MSXML2.XMLHTTP.6.0")

  xml.Open "GET", "https://" & userid & ":" & pwd & _
                  "@api.del.icio.us/v1/posts/dates?" & "tag=" & _
                  tag, False
  xml.Send

  result = xml.responseText

  ' create XML file from result
  Call CreateFile(tempFile, result)

  ' create XML doc
  Set xmlDoc = CreateObject("MSXML2.DOMDocument")

  With xmlDoc
    .async = False
    .validateOnParse = False
    .Load tempFile
  End With

  ' check that the XML doc loaded
  If LoadError(xmlDoc) Then
    Exit Function
  End If

  ' get first level nodes
  Set xmlDocRoot = GetRootNode(xmlDoc)
  Set dateNodes = GetChildNodes(xmlDocRoot)

  ' resize array
  ReDim tempString(1 To dateNodes.Length, 1 To 2)

  For i = 1 To dateNodes.Length

    Set dateNode = dateNodes.item(i - 1)

    tempString(i, 1) = dateNode.Attributes.getNamedItem("count").nodeTypedValue
    tempString(i, 2) = dateNode.Attributes.getNamedItem("date").nodeTypedValue

  Next i

  GetPostDates = tempString

End Function

Sample usage

This function returns the dates that bookmarks were added and how many were added on a given day.

Sub TestDelicious()

Dim tempString() As String
Dim userid As String
Dim password As String
Dim i As Long, j As Long

  userid = "some user id"
  password = "some password"

  tempString = GetPostDates(userid, password)
  For i = 1 To UBound(tempString)
    For j = 1 To UBound(tempString, 2)
      Debug.Print tempString(i, j)
    Next j
  Next i
End Sub

Return all bookmarks

This function will return all the bookmarks for a given user. You can filter this option several ways:

  • by tag
  • by date
  • by count

Check out the API documentation for a detailed description of the arguments.

Function GetAllPosts(userid As String, pwd As String, Optional tag As String, _
                     Optional fromDate As String, Optional toDate As String, _
                     Optional start As Long = 1, Optional numberOfResults As Long = 15, _
                     Optional meta As Boolean = False, Optional forceRefresh As Boolean = False) As String()

Dim xml As Object ' MSXML2.XMLHTTP
Dim result As String
Dim tempFile As String
Dim tempString() As String
Dim xmlDoc As Object ' MSXML2.DOMDocument
Dim xmlDocRoot As Object ' MSXML2.IXMLDOMNode
Dim posts As Object ' MSXML2.IXMLDOMNodeList
Dim post As Object ' MSXML2.IXMLDOMNode
Dim i As Long

  tempFile = environ("temp") & "\deliciousallposts.xml"

  If Len(Dir(tempFile)) = 0 Or forceRefresh Then

    Set xml = CreateObject("MSXML2.XMLHTTP.6.0")

    xml.Open "GET", "https://" & userid & ":" & pwd & _
                    "@api.del.icio.us/v1/posts/all?" & "tag=" & _
                    tag & "&start=" & start & _
                    "&results=" & numberOfResults & _
                    "&fromdt=" & fromDate & _
                    "&todt=" & toDate & _
                    "&meta=" & meta, False
    xml.Send

    result = xml.responseText

    ' create XML file from result
    Call CreateFile(tempFile, result)

  End If

  ' create XML doc
  Set xmlDoc = CreateObject("MSXML2.DOMDocument")

  With xmlDoc
    .async = False
    .validateOnParse = False
    .Load tempFile
  End With

  ' check that the XML doc loaded
  If LoadError(xmlDoc) Then
    Exit Function
  End If

  ' get first level nodes
  Set xmlDocRoot = GetRootNode(xmlDoc)
  Set posts = GetChildNodes(xmlDocRoot)

  ' resize array
  ReDim tempString(1 To posts.Length, 1 To 7)

  For i = 1 To posts.Length

    Set post = posts.item(i - 1)

    tempString(i, 1) = post.Attributes.getNamedItem("href").nodeTypedValue
    tempString(i, 2) = post.Attributes.getNamedItem("description").nodeTypedValue
    tempString(i, 3) = post.Attributes.getNamedItem("extended").nodeTypedValue
    tempString(i, 4) = post.Attributes.getNamedItem("hash").nodeTypedValue
    tempString(i, 5) = post.Attributes.getNamedItem("meta").nodeTypedValue
    tempString(i, 6) = post.Attributes.getNamedItem("tag").nodeTypedValue
    tempString(i, 7) = post.Attributes.getNamedItem("time").nodeTypedValue
  Next i

  GetAllPosts = tempString

End Function

Sample usage

Sub TestDelicious()

Dim tempString() As String
Dim userid As String
Dim password As String
Dim i As Long, j As Long

  userid = "some user id"
  password = "some password"

  tempString = GetAllPosts(userid, password, , , , , , True)
  For i = 1 To UBound(tempString)
    For j = 1 To UBound(tempString, 2)
      Debug.Print tempString(i, j)
    Next j
  Next i
End Sub

Get a change manifest of all bookmarks

Function GetChangeManifest(userid As String, pwd As String) As String()

Dim xml As Object ' MSXML2.XMLHTTP
Dim result As String
Dim tempFile As String
Dim tempString() As String
Dim xmlDoc As Object ' MSXML2.DOMDocument
Dim xmlDocRoot As Object ' MSXML2.IXMLDOMNode
Dim posts As Object ' MSXML2.IXMLDOMNodeList
Dim post As Object ' MSXML2.IXMLDOMNode
Dim i As Long

  tempFile = environ("temp") & "\deliciousposthashes.xml"

  Set xml = CreateObject("MSXML2.XMLHTTP.6.0")

  xml.Open "GET", "https://" & userid & ":" & pwd & _
                  "@api.del.icio.us/v1/posts/all?hashes", False
  xml.Send

  result = xml.responseText

  ' create XML file from result
  Call CreateFile(tempFile, result)

  ' create XML doc
  Set xmlDoc = CreateObject("MSXML2.DOMDocument")

  With xmlDoc
    .async = False
    .validateOnParse = False
    .Load tempFile
  End With

  ' check that the XML doc loaded
  If LoadError(xmlDoc) Then
    Exit Function
  End If

  ' get first level nodes
  Set xmlDocRoot = GetRootNode(xmlDoc)
  Set posts = GetChildNodes(xmlDocRoot)

  ' resize array
  ReDim tempString(1 To posts.Length, 1 To 2)

  For i = 1 To posts.Length

    Set post = posts.item(i - 1)

    tempString(i, 1) = post.Attributes.getNamedItem("meta").nodeTypedValue
    tempString(i, 2) = post.Attributes.getNamedItem("url").nodeTypedValue

  Next i

  GetChangeManifest = tempString

End Function

Sample usage

Sub TestDelicious()

Dim tempString() As String
Dim userid As String
Dim password As String
Dim i As Long, j As Long

  userid = "some user id"
  password = "some password"

  tempString = GetChangeManifest(userid, password)
  For i = 1 To UBound(tempString)
    For j = 1 To UBound(tempString, 2)
      Debug.Print tempString(i, j)
    Next j
  Next i
End Sub

Suggest tags for a given URL

Function SuggestTags(userid As String, pwd As String, url As String) As String()

Dim xml As Object ' MSXML2.XMLHTTP
Dim result As String
Dim tempFile As String
Dim tempString() As String
Dim xmlDoc As Object ' MSXML2.DOMDocument
Dim xmlDocRoot As Object ' MSXML2.IXMLDOMNode
Dim tags As Object ' MSXML2.IXMLDOMNodeList
Dim tag As Object ' MSXML2.IXMLDOMNode
Dim i As Long

  tempFile = environ("temp") & "\delicioustagssuggest.xml"

  Set xml = CreateObject("MSXML2.XMLHTTP.6.0")

  xml.Open "GET", "https://" & userid & ":" & pwd & _
                  "@api.del.icio.us/v1/posts/suggest?url=" & URLEncode(url), False
  xml.Send

  result = xml.responseText

  ' create XML file from result
  Call CreateFile(tempFile, result)

  ' create XML doc
  Set xmlDoc = CreateObject("MSXML2.DOMDocument")

  With xmlDoc
    .async = False
    .validateOnParse = False
    .Load tempFile
  End With

  ' check that the XML doc loaded
  If LoadError(xmlDoc) Then
    Exit Function
  End If

  ' get first level nodes
  Set xmlDocRoot = GetRootNode(xmlDoc)
  Set tags = GetChildNodes(xmlDocRoot)

  ' resize array
  ReDim tempString(1 To tags.Length)

  For i = 1 To tags.Length

    Set tag = tags.item(i - 1)

    Select Case tag.nodeName
      Case "recommended"
        tempString(i) = "recommended: " & tag.nodeTypedValue
      Case "popular"
        tempString(i) = "popular: " & tag.nodeTypedValue
      Case "network"
        tempString(i) = "network: " & tag.nodeTypedValue
    End Select

  Next i

  SuggestTags = tempString

End Function

Sample usage

Sub TestDelicious()

Dim tempString() As String
Dim userid As String
Dim password As String
Dim i As Long, j As Long

  userid = "some user id"
  password = "some password"

  tempString = SuggestTags(userid, password, "http://peltiertech.com/")
  For i = 1 To UBound(tempString)
    Debug.Print tempString(i)
  Next i
End Sub

Get tags used by a given user

Function GetTags(userid As String, pwd As String) As String()

Dim xml As Object ' MSXML2.XMLHTTP
Dim result As String
Dim tempFile As String
Dim tempString() As String
Dim xmlDoc As Object ' MSXML2.DOMDocument
Dim xmlDocRoot As Object ' MSXML2.IXMLDOMNode
Dim tags As Object ' MSXML2.IXMLDOMNodeList
Dim tag As Object ' MSXML2.IXMLDOMNode
Dim i As Long

  tempFile = environ("temp") & "\delicioustags.xml"

  Set xml = CreateObject("MSXML2.XMLHTTP.6.0")

  xml.Open "GET", "https://" & userid & ":" & pwd & _
                  "@api.del.icio.us/v1/tags/get", False
  xml.Send

  result = xml.responseText

  ' create XML file from result
  Call CreateFile(tempFile, result)

  ' create XML doc
  Set xmlDoc = CreateObject("MSXML2.DOMDocument")

  With xmlDoc
    .async = False
    .validateOnParse = False
    .Load tempFile
  End With

  ' check that the XML doc loaded
  If LoadError(xmlDoc) Then
    Exit Function
  End If

  ' get first level nodes
  Set xmlDocRoot = GetRootNode(xmlDoc)
  Set tags = GetChildNodes(xmlDocRoot)

  ' resize array
  ReDim tempString(1 To tags.Length, 1 To 2)

  For i = 1 To tags.Length

    Set tag = tags.item(i - 1)

    tempString(i, 1) = tag.Attributes.getNamedItem("count").nodeTypedValue
    tempString(i, 2) = tag.Attributes.getNamedItem("tag").nodeTypedValue

  Next i

  GetTags = tempString

End Function

Sample usage

Sub TestDelicious()

Dim tempString() As String
Dim userid As String
Dim password As String
Dim i As Long, j As Long

  userid = "some user id"
  password = "some password"

  tempString = GetTags(userid, password)
  For i = 1 To UBound(tempString)
    For j = 1 To UBound(tempString, 2)
      Debug.Print tempString(i, j)
    Next j
  Next i
End Sub

Delete given tag

Function DeleteTag(userid As String, pwd As String, tag As String) As Boolean

Dim xml As Object ' MSXML2.XMLHTTP
Dim result As String
Dim tempFile As String
Dim tempString() As String
Dim xmlDoc As Object ' MSXML2.DOMDocument
Dim xmlDocRoot As Object ' MSXML2.IXMLDOMNode
Dim resultCode As Object ' MSXML2.IXMLDOMNode

  tempFile = environ("temp") & "\deliciousdeletetag.xml"

  Set xml = CreateObject("MSXML2.XMLHTTP.6.0")

  xml.Open "GET", "https://" & userid & ":" & pwd & _
                  "@api.del.icio.us/v1/tags/delete?" & "tag=" & _
                  URLEncode(tag), False
  xml.Send

  result = xml.responseText

  ' create XML file from result
  Call CreateFile(tempFile, result)

  ' create XML doc
  Set xmlDoc = CreateObject("MSXML2.DOMDocument")

  With xmlDoc
    .async = False
    .validateOnParse = False
    .Load tempFile
  End With

  ' check that the XML doc loaded
  If LoadError(xmlDoc) Then
    Exit Function
  End If

  ' get first level nodes
  Set resultCode = xmlDoc.childNodes(1)

  DeleteTag = (resultCode.nodeTypedValue = "done")

End Function

Sample usage

Sub TestDelicious()

Dim tempString() As String
Dim userid As String
Dim password As String
Dim i As Long, j As Long

  userid = "some user id"
  password = "some password"

  Debug.Print DeleteTag(userid, password, "wordpress")

End Sub

Rename tags

Function RenameTag(userid As String, pwd As String, oldTag As String, newTag As String) As Boolean

Dim xml As Object ' MSXML2.XMLHTTP
Dim result As String
Dim tempFile As String
Dim tempString() As String
Dim xmlDoc As Object ' MSXML2.DOMDocument
Dim xmlDocRoot As Object ' MSXML2.IXMLDOMNode
Dim resultCode As Object ' MSXML2.IXMLDOMNode

  tempFile = environ("temp") & "\deliciousrenametag.xml"

  Set xml = CreateObject("MSXML2.XMLHTTP.6.0")

  xml.Open "GET", "https://" & userid & ":" & pwd & _
                  "@api.del.icio.us/v1/tags/rename?" & "old=" & _
                  URLEncode(oldTag) & "&new=" & URLEncode(newTag), False
  xml.Send

  result = xml.responseText

  ' create XML file from result
  Call CreateFile(tempFile, result)

  ' create XML doc
  Set xmlDoc = CreateObject("MSXML2.DOMDocument")

  With xmlDoc
    .async = False
    .validateOnParse = False
    .Load tempFile
  End With

  ' check that the XML doc loaded
  If LoadError(xmlDoc) Then
    Exit Function
  End If

  ' get first level nodes
  Set resultCode = xmlDoc.childNodes(1)

  RenameTag = (resultCode.nodeTypedValue = "done")

End Function

Sample usage

Sub TestDelicious()

Dim tempString() As String
Dim userid As String
Dim password As String
Dim i As Long, j As Long

  userid = "some user id"
  password = "some password"

  Debug.Print RenameTag(userid, password, "outlook", "Outlook 2003")

End Sub
About JP

I'm just an average guy who writes VBA code for a living. This is my personal blog. Excel and Outlook are my thing, with a sprinkle of Access and Word here and there. Follow this space to learn more about VBA. Keep Reading »



Share This Article:

Share and bookmark this articledelicious buttonfacebook buttonlinkedin buttonstumbleupon buttontwitter button

This article is closed to any future comments.
excel school learn dashboards