Commits

Hideya OHASHI committed e8802ad

show shout form if location is near by venue (within 5 meters)

  • Participants
  • Parent commits 0b07aaf

Comments (0)

Files changed (2)

File src/com/appspot/ktai4sq/VenuesServlet.scala

     val c = URLFetchServiceFactory.getURLFetchService().fetch(req).getContent()
     XML.loadString(new String(c, "UTF-8"))
   }
-  def checkin(vid: int, token: String, secret: String): Unit = {
+  def checkin(vid: int, token: String, secret: String, shout: String): Unit = {
     val url = "http://api.foursquare.com/v1/checkin"
     val req = getHTTPRequest(url, HTTPMethod.POST, token, secret)
-    req.setPayload("vid=%d".format(vid).getBytes())
+    val s = if (shout == null) "" else "&shout=%s".format(shout)
+    req.setPayload("vid=%d%s".format(vid, s).getBytes())
     URLFetchServiceFactory.getURLFetchService().fetch(req).getContent()
   }
   def aamap(vs2: Seq[java.util.List[String]], lx: double,
     }
     var ci = req.getParameter("i")
     if (ci != null) {
-      checkin(ci.toInt, token, secret)
+      val shout = req.getParameter("c")
+      checkin(ci.toInt, token, secret, shout)
       resp.sendRedirect(url)
       return
     }

File www/venues.jsp

 <a href="?l=<c:out value="${venue[3]},${venue[4]}"/>">TO</a>
 <c:if test="${token != null}">
 <a href="?i=<c:out value="${venue[0]}"/>">IN</a>
+<c:if test="${venue[2] != '' && venue[2] < 5}">
+<form method="get" action="/v">
+<input type="hidden" name="i" value="<c:out value="${venue[0]}"/>"></input>
+<input type="text" name="c" value=""></input>
+<input type="submit" value="shout"></input>
+</form>
+</c:if>
 </c:if>
 <br>
 </c:forEach>