Commits

Hideya OHASHI committed 934bf52

show latest checkin venues from users history

Comments (0)

Files changed (1)

src/com/appspot/ktai4sq/VenuesServlet.scala

     }
     req
   }
+  def history(token: String, secret: String): Elem = {
+    val urlf = "http://api.foursquare.com/v1/history"
+    val req = getHTTPRequest(urlf, HTTPMethod.GET, token, secret)
+    val c = URLFetchServiceFactory.getURLFetchService().fetch(req).getContent()
+    XML.loadString(new String(c, "UTF-8"))
+  }
   def venues(geolat: double, geolong: double, token: String,
       secret: String): Elem = {
     val urlf = "http://api.foursquare.com/v1/venues?geolat=%f&geolong=%f"
       val s = List("@ABCDEFGHIJKLMNOPQRSTUVWXYZ".substring(i, i + 1))
       Arrays.asList((keys.map(v \ _).map(_.text) ++ s).toArray: _*)
     }
+    val hi = history(token, secret) \\ "checkins" \ "checkin" \ "venue"
+    val vs3 = for (v <- hi) yield {
+      Arrays.asList((keys.map(v \ _).map(_.text) ++ "_").toArray: _*)
+    }
     val aam = aamap(vs2, ll2(1), ll2(0))
     val aa = aam._1
     val wx = aam._2
     req.setAttribute("au", au)
     req.setAttribute("docomo", docomo)
     req.setAttribute("token", token)
-    req.setAttribute("venues", Arrays.asList(vs2.toArray: _*))
+    req.setAttribute("venues", Arrays.asList((vs2 ++ vs3).toArray: _*))
     req.setAttribute("aa", aa)
     val move = List((-wx, -wy), (-wx, wy), (wx, -wy), (wx, wy)).map { (t) =>
       "?l=%f,%f".format(ll2(0) + t._2, ll2(1) + t._1)