Public Sub Handle(req As ServletRequest, resp As ServletResponse)
' si memorizza l'oggetto resp servlet
respGlobal = resp
Try
BitlyAnalytics(req.GetParameter("link_to_check"))
Catch
resp.ContentType = "application/json; charset=UTF-8"
resp.Write(Main.GeneraErrorJson(500,"Handle Error"))
resp.Status = 500
End Try
StartMessageLoop
End Sub
Public Sub BitlyAnalytics(ShortUrlToCheck As String)
Dim hjAnalytics As HttpJob
Try
hjAnalytics.Initialize("hjAnalytics", Me)
hjAnalytics.Download2(EncodeUrl(UrlAnalytics), Array As String("access_token", AccessToken, "link", EncodeUrl(ShortUrlToCheck)))
hjAnalytics.GetRequest.Timeout = 10000
hjAnalytics.Tag = ShortUrlToCheck
Catch
log("ERRORE DURANTE LA RICHIESTA ANALYTICS A BITLY. RIPROVARE")
End Try
End Sub
Private Sub JobDone (Job As HttpJob)
If Success = True Then
Dim mResponse As Map
Dim jsonError As JSONGenerator
jsonError.Initialize2(lRequests)
mResponse.Initialize
mResponse.Put("responseCode", 0)
mResponse.Put("responseDescription", "Query Successfully")
mResponse.Put("Requests", jsonError.ToString)
Log(jsonError.ToString)
jsonError.Initialize(mResponse)
Log(jsonError.ToString)
respGlobal.ContentType = "application/json"
respGlobal.Write(jsonError.ToString)
respGlobal.Status = 200
Else
respGlobal.ContentType = "application/json; charset=UTF-8"
respGlobal.Write(Main.GeneraErrorJson(400,Result))
respGlobal.Status = 200
End If
Job.Release
StopMessageLoop
End Sub