Android Question Google civic api using curl

lamont Thomas

New Member
Licensed User
Longtime User
OK. I wrote the following:

Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")

Dim job2, job3 As HttpJob





'Send a POST request
'job2.Initialize("Job2", Me)
'job2.PostString("http://www.b4x.com/print.php", "first key=first value&key2=value2")
job2.Initialize("job2",Me)
'job2.Initailize("job2", Me)
link = "https://www.googleapis.com/civicinfo/us_v1/voterinfo/2000/lookup?key=<API_Key>"
job2.PostString(link, "{ 'address': '1263 Pacific Ave. Kansas City KS' }")

job2.GetRequest.SetContentType("application/json")


End Sub

Sub JobDone (Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
Select Job.JobName
Case "Job2"
'print the result to the logs
Log("bye" )

End Select
Else
Log("Error: " & Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub

The log out put is:
** Activity (main) Pause, UserClosed = true **
** Activity (main) Resume **
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:b4a.example
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
JobName = job2, Success = true
JobName = Job3, Success = true
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **

But I do not know how to get the json that is being returned and parse it.
Please help.
 
Upvote 0

lamont Thomas

New Member
Licensed User
Longtime User
First thank you for your reply.
Second, When you state "Please use [ code ] [ /code ] tags (without spaces) when posting code." What do you mean. Can you point me to an example. I am new to this and would like to learn.
 
Upvote 0
Top