Dim param As New Dictionary(Of String, String)
param.Add("cursor", cursor.ToString())
Return httpCon.GetContent(GetMethod, _
- CreateTwitterUri("/1/" + user + "/" + list_id + "/members.xml"), _
+ CreateTwitterUri("/1/" + user + "/" + list_id + "/members.json"), _
param, _
content, _
TwitterApiInfo.HttpHeaders, _
Dim param As New Dictionary(Of String, String)
param.Add("id", id)
Return httpCon.GetContent(PostMethod, _
- CreateTwitterUri("/1/" + user + "/" + list_id + "/members.xml"), _
+ CreateTwitterUri("/1/" + user + "/" + list_id + "/members.json"), _
param, _
content, _
Nothing, _
param.Add("id", id)
param.Add("_method", "DELETE")
Return httpCon.GetContent(PostMethod, _
- CreateTwitterUri("/1/" + user + "/" + list_id + "/members.xml"), _
+ CreateTwitterUri("/1/" + user + "/" + list_id + "/members.json"), _
param, _
content, _
Nothing, _
Public Function GetListMembersID(ByVal user As String, ByVal list_id As String, ByVal id As String, ByRef content As String) As HttpStatusCode
Return httpCon.GetContent(GetMethod, _
- CreateTwitterUri("/1/" + user + "/" + list_id + "/members/" + id + ".xml"), _
+ CreateTwitterUri("/1/" + user + "/" + list_id + "/members/" + id + ".json"), _
Nothing, _
content, _
TwitterApiInfo.HttpHeaders, _
End If
Return httpCon.GetContent(GetMethod, _
- CreateTwitterUri("/1/statuses/" + statusid.ToString + "/retweeted_by/ids.xml"), _
+ CreateTwitterUri("/1/statuses/" + statusid.ToString + "/retweeted_by/ids.json"), _
param, _
content, _
TwitterApiInfo.HttpHeaders, _
param.Add("description", description)
Return httpCon.GetContent(PostMethod, _
- CreateTwitterUri("/1/account/update_profile.xml"), _
+ CreateTwitterUri("/1/account/update_profile.json"), _
param, _
content, _
Nothing, _
binary.Add(New KeyValuePair(Of String, FileInfo)("image", imageFile))
Return httpCon.GetContent(PostMethod, _
- CreateTwitterUri("/1/account/update_profile_image.xml"), _
+ CreateTwitterUri("/1/account/update_profile_image.json"), _
Nothing, _
binary, _
content, _
Select Case res
Case HttpStatusCode.OK
- Dim xdoc As New XmlDocument
- Dim xnode As XmlNodeList
- Dim result As String = ""
- Twitter.AccountState = ACCOUNT_STATE.Valid
Try
- xdoc.LoadXml(content)
- xnode = xdoc.GetElementsByTagName("ids")
- retweeted_count += xnode.ItemOf(0).ChildNodes.Count
- If xnode.ItemOf(0).ChildNodes.Count < 100 Then Exit For
+ Dim ids As Int64() = CreateDataFromJson(Of Int64())(content)
+ retweeted_count += ids.Length
+ If ids.Length < 100 Then Exit For
+ Catch ex As SerializationException
+ retweeted_count = -1
+ TraceOut(ex.Message + Environment.NewLine + content)
+ Return "Err:Json Parse Error(DataContractJsonSerializer)"
Catch ex As Exception
retweeted_count = -1
- result = "Err:Invalid XML."
- xmlBuf = Nothing
+ TraceOut(content)
+ Return "Err:Invalid Json!"
End Try
Case HttpStatusCode.BadRequest
retweeted_count = -1
Twitter.AccountState = ACCOUNT_STATE.Invalid
Return "Check your Username/Password."
Case HttpStatusCode.Forbidden
- Dim xd As XmlDocument = New XmlDocument
- Try
- xd.LoadXml(content)
- Dim xNode As XmlNode = Nothing
- xNode = xd.SelectSingleNode("/hash/error")
- Return "Err:" + xNode.InnerText + "(" + GetCurrentMethod.Name + ")"
- Catch ex As Exception
- Return "Err:Forbidden" + "(" + GetCurrentMethod.Name + ")"
- End Try
+ Dim errMsg As String = GetErrorMessageJson(content)
+ If String.IsNullOrEmpty(errMsg) Then
+ Return "Err:Forbidden(" + GetCurrentMethod.Name + ")"
+ Else
+ Return "Err:" + errMsg
+ End If
Case Else
Return "Err:" + res.ToString + "(" + GetCurrentMethod.Name + ")"
End Select
Twitter.AccountState = ACCOUNT_STATE.Invalid
Return "Check your Username/Password."
Case HttpStatusCode.Forbidden
- Dim xd As XmlDocument = New XmlDocument
- Try
- xd.LoadXml(content)
- Dim xNode As XmlNode = Nothing
- xNode = xd.SelectSingleNode("/hash/error")
- Return "Err:" + xNode.InnerText + "(" + GetCurrentMethod.Name + ")"
- Catch ex As Exception
- Return "Err:Forbidden" + "(" + GetCurrentMethod.Name + ")"
- End Try
+ Dim errMsg As String = GetErrorMessageJson(content)
+ If String.IsNullOrEmpty(errMsg) Then
+ Return "Err:Forbidden(" + GetCurrentMethod.Name + ")"
+ Else
+ Return "Err:" + errMsg
+ End If
Case Else
Return "Err:" + res.ToString + "(" + GetCurrentMethod.Name + ")"
End Select
Dim res As HttpStatusCode
Dim content As String = ""
- 'Dim cursor As Long = -1
'Do
Try
Return "Err:" + res.ToString() + "(" + GetCurrentMethod.Name + ")"
End Select
- Dim xdoc As New XmlDocument
- Try
- xdoc.LoadXml(content)
- Catch ex As Exception
- TraceOut(content)
- Return "Invalid XML!"
- End Try
-
Try
- For Each xentryNode As XmlNode In xdoc.DocumentElement.SelectNodes("/users_list/users/user")
- lists.Add(New UserInfo(xentryNode))
- Next
- cursor = Long.Parse(xdoc.DocumentElement.SelectSingleNode("/users_list/next_cursor").InnerText)
+ Dim users = CreateDataFromJson(Of TwitterDataModel.Users)(content)
+ Array.ForEach(Of TwitterDataModel.User)(
+ users.users,
+ New Action(Of TwitterDataModel.User)(Sub(u)
+ lists.Add(New UserInfo(u))
+ End Sub))
+ cursor = users.NextCursor
+ Return ""
+ Catch ex As SerializationException
+ TraceOut(ex.Message + Environment.NewLine + content)
+ Return "Err:Json Parse Error(DataContractJsonSerializer)"
Catch ex As Exception
TraceOut(content)
- Return "Invalid XML!"
+ Return "Err:Invalid Json!"
End Try
- 'Loop While cursor <> 0
Return ""
End Function
Return "Err:" + res.ToString() + "(" + GetCurrentMethod.Name + ")"
End Select
- Dim xdoc As New XmlDocument
Try
- xdoc.LoadXml(content)
- value = xdoc.DocumentElement.Name = "user"
+ Dim u = CreateDataFromJson(Of TwitterDataModel.User)(content)
+ value = True
+ Return ""
Catch ex As Exception
- TraceOut(content)
- Return "Invalid XML!"
+ value = False
+ Return ""
End Try
-
- Return ""
End Function
Public Function AddUserToList(ByVal list_name As String, ByVal user As String) As String
Return "Err:" + ex.Message + "(" + GetCurrentMethod.Name + ")"
End Try
+ Select Case res
+ Case HttpStatusCode.OK
+ Twitter.AccountState = ACCOUNT_STATE.Valid
+ Case HttpStatusCode.Unauthorized
+ Twitter.AccountState = ACCOUNT_STATE.Invalid
+ Return "Check your Username/Password."
+ Case HttpStatusCode.BadRequest
+ Return "Err:API Limits?"
+ Case Else
+ Return "Err:" + res.ToString() + "(" + GetCurrentMethod.Name + ")"
+ End Select
+
Return ""
End Function
Return "Err:" + ex.Message + "(" + GetCurrentMethod.Name + ")"
End Try
+ Select Case res
+ Case HttpStatusCode.OK
+ Twitter.AccountState = ACCOUNT_STATE.Valid
+ Case HttpStatusCode.Unauthorized
+ Twitter.AccountState = ACCOUNT_STATE.Invalid
+ Return "Check your Username/Password."
+ Case HttpStatusCode.BadRequest
+ Return "Err:API Limits?"
+ Case Else
+ Return "Err:" + res.ToString() + "(" + GetCurrentMethod.Name + ")"
+ End Select
+
Return ""
End Function
Debug.Print("delete")
Dim post As PostClass = Nothing
Dim id As Int64
- If xElm.Element("delete").Element("direct_message") IsNot Nothing Then
+ If xElm.Element("delete").Element("direct_message") IsNot Nothing AndAlso
+ xElm.Element("delete").Element("direct_message").Element("id") IsNot Nothing Then
id = CLng(xElm.Element("delete").Element("direct_message").Element("id").Value)
RaiseEvent PostDeleted(id, post)
- Else
+ ElseIf xElm.Element("delete").Element("status") IsNot Nothing AndAlso
+ xElm.Element("delete").Element("status").Element("id") IsNot Nothing Then
id = CLng(xElm.Element("delete").Element("status").Element("id").Value)
RaiseEvent PostDeleted(id, post)
+ Else
+ TraceOut("delete:" + line)
+ Exit Sub
End If
CreateDeleteEvent(DateTime.Now, id, post)
Exit Sub
Debug.Print("direct_message")
isDm = True
ElseIf xElm.Element("scrub_geo") IsNot Nothing Then
- Debug.Print("scrub_geo: user_id=" + xElm.Element("user_id").Value.ToString + " up_to_status_id=" + xElm.Element("up_to_status_id").Value.ToString)
+ Try
+ Debug.Print("scrub_geo: user_id=" + xElm.Element("user_id").Value.ToString + " up_to_status_id=" + xElm.Element("up_to_status_id").Value.ToString)
+ Catch ex As Exception
+ TraceOut("scrub_geo:" + line)
+ End Try
Exit Sub
End If
End Using
End Sub
- Public Sub New(ByVal xmlNode As Xml.XmlNode)
- Me.Id = Long.Parse(xmlNode.Item("id").InnerText)
- Me.Name = xmlNode.Item("name").InnerText
- Me.ScreenName = xmlNode.Item("screen_name").InnerText
- Me.Location = xmlNode.Item("location").InnerText
- Me.Description = xmlNode.Item("description").InnerText
- Me.ImageUrl = New Uri(xmlNode.Item("profile_image_url").InnerText)
- Me.Url = xmlNode.Item("url").InnerText
- Me.Protect = Boolean.Parse(xmlNode.Item("protected").InnerText)
- Me.FriendsCount = Integer.Parse(xmlNode.Item("friends_count").InnerText)
- Me.FollowersCount = Integer.Parse(xmlNode.Item("followers_count").InnerText)
- Me.CreatedAt = DateTime.ParseExact(xmlNode.Item("created_at").InnerText, "ddd MMM dd HH:mm:ss zzzz yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo, System.Globalization.DateTimeStyles.None)
- Me.StatusesCount = Integer.Parse(xmlNode.Item("statuses_count").InnerText)
- Me.Verified = Boolean.Parse(xmlNode.Item("verified").InnerText)
- Me.isFollowing = Boolean.Parse(xmlNode.Item("following").InnerText)
- Dim postNode As Xml.XmlNode = xmlNode.Item("status")
- Me.RecentPost = postNode.Item("text").InnerText
- Me.PostCreatedAt = DateTime.ParseExact(postNode.Item("created_at").InnerText, "ddd MMM dd HH:mm:ss zzzz yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo, System.Globalization.DateTimeStyles.None)
- Me.PostSource = postNode.Item("source").InnerText
+ Public Sub New(ByVal user As TwitterDataModel.User)
+ Me.Id = user.Id
+ Me.Name = user.Name
+ Me.ScreenName = user.ScreenName
+ Me.Location = user.Location
+ Me.Description = user.Description
+ Try
+ Me.ImageUrl = New Uri(user.ProfileImageUrl)
+ Catch ex As Exception
+ Me.ImageUrl = Nothing
+ End Try
+ Me.Url = user.Url
+ Me.Protect = user.Protected
+ Me.FriendsCount = user.FriendsCount
+ Me.FollowersCount = user.FollowersCount
+ Me.CreatedAt = DateTimeParse(user.CreatedAt)
+ Me.StatusesCount = user.StatusesCount
+ Me.Verified = user.Verified
+ Me.isFollowing = Me.isFollowing
+ If user.Status IsNot Nothing Then
+ Me.RecentPost = user.Status.Text
+ Me.PostCreatedAt = DateTimeParse(user.Status.CreatedAt)
+ Me.PostSource = user.Status.Source
+ End If
End Sub
Public Id As Int64 = 0