[Tween-svn] [1093] ・home_timeline , mentionsでEntities取得を有効に

Zurück zum Archiv-Index

svnno****@sourc***** svnno****@sourc*****
2010年 11月 22日 (月) 20:14:08 JST


Revision: 1093
          http://sourceforge.jp/projects/tween/svn/view?view=rev&revision=1093
Author:   syo68k
Date:     2010-11-22 20:14:08 +0900 (Mon, 22 Nov 2010)

Log Message:
-----------
・home_timeline,mentionsでEntities取得を有効に
・PublicTimelineメソッドを新設(デバッグ用、現在は未使用)
・Jsonシリアライズ、日付解析時の例外処理見直し

Modified Paths:
--------------
    branches/UserStream/Tween/Connection/HttpTwitter.vb
    branches/UserStream/Tween/Twitter.vb


-------------- next part --------------
Modified: branches/UserStream/Tween/Connection/HttpTwitter.vb
===================================================================
--- branches/UserStream/Tween/Connection/HttpTwitter.vb	2010-11-22 08:28:56 UTC (rev 1092)
+++ branches/UserStream/Tween/Connection/HttpTwitter.vb	2010-11-22 11:14:08 UTC (rev 1093)
@@ -321,6 +321,8 @@
             param.Add("since_id", since_id.ToString())
         End If
 
+        param.Add("include_entities", "true")
+
         Return httpCon.GetContent(GetMethod, _
                             CreateTwitterUri("/1/statuses/home_timeline.json"), _
                             param, _
@@ -329,6 +331,28 @@
                             AddressOf GetApiCallback)
     End Function
 
+    Public Function PublicTimeline(ByVal count As Integer, ByVal max_id As Long, ByVal since_id As Long, ByRef content As String) As HttpStatusCode
+        Dim param As New Dictionary(Of String, String)
+        If count > 0 Then
+            param.Add("count", count.ToString())
+        End If
+        If max_id > 0 Then
+            param.Add("max_id", max_id.ToString())
+        End If
+        If since_id > 0 Then
+            param.Add("since_id", since_id.ToString())
+        End If
+
+        param.Add("include_entities", "true")
+
+        Return httpCon.GetContent(GetMethod, _
+                            CreateTwitterUri("/1/statuses/public_timeline.json"), _
+                            param, _
+                            content, _
+                            TwitterApiInfo.HttpHeaders, _
+                            AddressOf GetApiCallback)
+    End Function
+
     Public Function Mentions(ByVal count As Integer, ByVal max_id As Long, ByVal since_id As Long, ByRef content As String) As HttpStatusCode
         Dim param As New Dictionary(Of String, String)
         If count > 0 Then
@@ -341,6 +365,8 @@
             param.Add("since_id", since_id.ToString())
         End If
 
+        param.Add("include_entities", "true")
+
         Return httpCon.GetContent(GetMethod, _
                             CreateTwitterUri("/1/statuses/mentions.json"), _
                             param, _

Modified: branches/UserStream/Tween/Twitter.vb
===================================================================
--- branches/UserStream/Tween/Twitter.vb	2010-11-22 08:28:56 UTC (rev 1092)
+++ branches/UserStream/Tween/Twitter.vb	2010-11-22 11:14:08 UTC (rev 1093)
@@ -32,6 +32,7 @@
 Imports System.Net
 Imports System.Reflection
 Imports System.Reflection.MethodBase
+Imports System.Runtime.Serialization
 Imports System.Runtime.Serialization.Json
 
 
@@ -1412,6 +1413,9 @@
         ' エラーチェックはまだ行わない
         Try
             item = DirectCast(serializer.ReadObject(stream), List(Of DataModel.status))
+        Catch ex As SerializationException
+            TraceOut(ex.Message + Environment.NewLine + content)
+            Return "Json Parse Error(DataContractJsonSerializer)"
         Catch ex As Exception
             TraceOut(content)
             Return "Invalid Json!"
@@ -1433,7 +1437,13 @@
                 End SyncLock
                 If status.retweeted_status IsNot Nothing Then
                     Dim retweeted As DataModel.retweeted_status = status.retweeted_status
-                    post.PDate = DateTime.ParseExact(retweeted.created_at, "ddd MMM dd HH:mm:ss zzzz yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo, System.Globalization.DateTimeStyles.None)
+
+                    Try
+                        post.PDate = DateTime.ParseExact(retweeted.created_at, "ddd MMM dd HH:mm:ss zzzz yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo, System.Globalization.DateTimeStyles.None)
+                    Catch ex As Exception
+                        TraceOut("Parse Error:retweeted_status.created_at : " + retweeted.created_at + Environment.NewLine + content)
+                        Continue For
+                    End Try
                     'Id
                     post.RetweetedId = retweeted.id
                     '本文
@@ -1457,7 +1467,12 @@
                     'Retweetした人
                     post.RetweetedBy = status.user.screen_name
                 Else
-                    post.PDate = DateTime.ParseExact(status.created_at, "ddd MMM dd HH:mm:ss zzzz yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo, System.Globalization.DateTimeStyles.None)
+                    Try
+                        post.PDate = DateTime.ParseExact(status.created_at, "ddd MMM dd HH:mm:ss zzzz yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo, System.Globalization.DateTimeStyles.None)
+                    Catch ex As Exception
+                        TraceOut("Parse Error:created_at : " + status.created_at + Environment.NewLine + content)
+                        Continue For
+                    End Try
                     '本文
                     post.Data = status.text
                     'Source取得(htmlの場合は、中身を取り出し)



Tween-svn メーリングリストの案内
Zurück zum Archiv-Index