OSDN Git Service

Searchでsince_id指定するよう変更
authorkiri_feather <kiri_feather@users.sourceforge.jp>
Fri, 28 May 2010 01:11:54 +0000 (01:11 +0000)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 18 Feb 2012 14:12:53 +0000 (23:12 +0900)
git-svn-id: http://svn.sourceforge.jp/svnroot/tween/trunk@386 e39ad16e-3079-482e-bb30-4b4d378143b6

Tween/Connection/HttpTwitter.vb
Tween/StatusDictionary.vb
Tween/Twitter.vb

index f28e91f..172237d 100644 (file)
@@ -348,12 +348,13 @@ Public Class HttpTwitter
                             _remainCountApi)
     End Function
 
-    Public Function Search(ByVal words As String, ByVal lang As String, ByVal rpp As Integer, ByVal page As Integer, ByRef content As String) As HttpStatusCode
+    Public Function Search(ByVal words As String, ByVal lang As String, ByVal rpp As Integer, ByVal page As Integer, ByVal sinceId As Long, ByRef content As String) As HttpStatusCode
         Dim param As New Dictionary(Of String, String)
         If Not String.IsNullOrEmpty(words) Then param.Add("q", words)
         If Not String.IsNullOrEmpty(lang) Then param.Add("lang", lang)
         If rpp > 0 Then param.Add("rpp", rpp.ToString())
         If page > 0 Then param.Add("page", page.ToString())
+        If sinceId > 0 Then param.Add("since_id", sinceId.ToString)
 
         If param.Count = 0 Then Return HttpStatusCode.BadRequest
 
index 13907b8..05d75ba 100644 (file)
@@ -1366,6 +1366,7 @@ Public NotInheritable Class TabClass
     Private _posts As New Dictionary(Of Long, PostClass)
     Private _sorter As New IdComparerClass
     Private _oldestId As Long = Long.MaxValue   '古いポスト取得用
+    Private _sinceId As Long = 0
 
 #Region "検索"
     'Search query
@@ -1444,6 +1445,16 @@ Public NotInheritable Class TabClass
     End Property
 
     <Xml.Serialization.XmlIgnore()> _
+    Public Property SinceId() As Long
+        Get
+            Return _sinceId
+        End Get
+        Set(ByVal value As Long)
+            _sinceId = value
+        End Set
+    End Property
+
+    <Xml.Serialization.XmlIgnore()> _
     Public Property Posts() As Dictionary(Of Long, PostClass)
         Get
             Return _posts
index d5d44ab..807016c 100644 (file)
@@ -1537,9 +1537,15 @@ Public Class Twitter
         Dim res As HttpStatusCode
         Dim content As String = ""
         Dim page As Integer = 0
-        If more Then page = tab.SearchPage
+        Dim sinceId As Long = 0
+        If more Then
+            page = tab.SearchPage
+        Else
+            sinceId = tab.SinceId
+        End If
+
         Try
-            res = twCon.Search(tab.SearchWords, tab.SearchLang, 40, page, content)
+            res = twCon.Search(tab.SearchWords, tab.SearchLang, 40, page, sinceId, content)
         Catch ex As Exception
             Return "Err:" + ex.Message
         End Try
@@ -1617,6 +1623,7 @@ Public Class Twitter
                 If post.IsMe AndAlso Not read AndAlso _readOwnPost Then post.IsRead = True
                 post.IsDm = False
                 post.RelTabName = tab.TabName
+                If Not more AndAlso post.Id > tab.SinceId Then tab.SinceId = post.Id
             Catch ex As Exception
                 TraceOut(content)
                 Continue For