Communicate with server using PUT

Ralph DiMola rdimola at evergreeninfo.net
Thu Jun 27 10:45:46 EDT 2013


I apologize for being lazy but I have used the CSZ acronym for 20 years. It
stands for "City State Zip".
I found that just sending the zip yields the best results.
Examples:

put GeoCode("455 Park Ave suite 4401" , "10011") into Geo
put GeoCode("54 Main Street" , "12801") into Geo

GeoCode returns an array with the these keys: 
["Lat"]["Center"]
["Lon["Center"]
["Status"]
["LocationType"]
["PartialMatch"]





Ralph DiMola
IT Director
Evergreen Information Services
rdimola at evergreeninfo.net


-----Original Message-----
From: use-livecode [mailto:use-livecode-bounces at lists.runrev.com] On Behalf
Of Thomas McGrath III
Sent: Thursday, June 27, 2013 10:07 AM
To: How to use LiveCode
Subject: Re: Communicate with server using PUT

Ralph, I'm trying to learn about the Google api and understand your code and
wanted to know what is expected in CSZ to feed to this function? what is
your typical line of code that calls this function?

Thanks

-- Tom McGrath III
http://lazyriver.on-rev.com
mcgrath3 at mac.com

On Jun 26, 2013, at 8:03 PM, Ralph DiMola <rdimola at evergreeninfo.net> wrote:

> J,
> 
> Well I guess no attachments on the list. Here it is in-line.
> 
> function GeoCode StreetAddress , CSZ
> 
>   --Status Codes
>   --"OK" indicates that no errors occurred; the address was 
> successfully parsed and at least one geocode was returned.
>   --"ZERO_RESULTS" indicates that the geocode was successful but 
> returned no results. This may occur if the geocode was passed a 
> non-existent address or a latlng in a remote location.
>   --"OVER_QUERY_LIMIT" indicates that you are over your quota.
>   --"REQUEST_DENIED" indicates that your request was denied, generally 
> because of lack of a sensor parameter.
>   --"INVALID_REQUEST"generally indicates that the query (address or 
> latlng) is missing
> 
> 
>   --Location Types
>   --"ROOFTOP" indicates that the returned result is a precise geocode 
> for which we have location information accurate down to street
>   --     address precision.
>   --"RANGE_INTERPOLATED" indicates that the returned result reflects 
> an approximation (usually on a road) interpolated between two
>   --    precise points (such as intersections). Interpolated results are
> generally returned when rooftop geocodes are unavailable
>   --    for a street address.
>   --"GEOMETRIC_CENTER" indicates that the returned result is the 
> geometric center of a result such as a polyline (for example, a street)
>   --    or polygon (region).
>   --"APPROXIMATE" indicates that the returned result is approximate
> 
>   local gxml , txml , str1 , pos1 , add1 , I , str2
>   Local Geo
> 
>   put empty into Geo
>   repeat with I = 1 to the number of lines in StreetAddress
>      put offset ("#",line I of StreetAddress) into pos1
>      if pos1 <> 0 then put char 1 to (pos1-1) of line I of 
> StreetAddress into line I of Streetaddress
>      Replace "  " with " " in line I of StreetAddress
>      replace " " with "+" in line I of StreetAddress
>      put Add1 && Line I of Streetaddress into Add1
>   end repeat
>   delete char 1 in Add1
>   Replace "  " with " " in CSZ
>   replace " " with "+" in CSZ
> 
>   put url  ("http://maps.googleapis.com/maps/api/geocode/xml?address=" 
> &
> add1 & comma & "+" & CSZ & "&sensor=false") into gxml
>   delete line 1 in gxml
>   put revCreateXMLTree(gxml,true,true,false) into txml
>   put revxmlnodecontents(txml,"GeocodeResponse/status") into geo["Status"]
>   replace "OVER_" with "" in geo["Status"]
>   if revxmlnodecontents(txml,"GeocodeResponse/status") = "OK" then
>      if 
> xmlnodecontents(txml,"GeocodeResponse/result/formatted_address") is not
empty then \
>            put
> xmlnodecontents(txml,"GeocodeResponse/result/formatted_address") into 
> Geo["FormattedAddress"]
>      put xmlnodecontents(txml,"GeocodeResponse/result/partial_match") 
> into Geo["PartialMatch"]
>      repeat with I = 1 to
>
revxmlnumberofchildren(txml,"/GeocodeResponse/result","address_component",1)
>         switch
> revxmlnodecontents(txml,"GeocodeResponse/result/address_component[" & 
> I &
> "]/type")
>            Case "administrative_area_level_2"
>               put
> revxmlnodecontents(txml,"GeocodeResponse/result/address_component[" & 
> I &
> "]/long_name")  into geo["County"]
>               Break
>            Case "administrative_area_level_3"
>               put
> revxmlnodecontents(txml,"GeocodeResponse/result/address_component[" & 
> I &
> "]/long_name")  into geo["City"]
>               Break
>            Case "street_number"
>               put
> revxmlnodecontents(txml,"GeocodeResponse/result/address_component[" & 
> I &
> "]/long_name")  into geo["StreetNumber"]
>               Break   
>            Case "route"
>               put
> revxmlnodecontents(txml,"GeocodeResponse/result/address_component[" & 
> I &
> "]/long_name")  into geo["Route"]
>               Break   
>            Case "locality"
>               put
> revxmlnodecontents(txml,"GeocodeResponse/result/address_component[" & 
> I &
> "]/long_name")  into geo["City"]
>               Break
>            Case "administrative_area_level_1"
>               put
> revxmlnodecontents(txml,"GeocodeResponse/result/address_component[" & 
> I &
> "]/long_name")  into geo["StateName"]
>               put
> revxmlnodecontents(txml,"GeocodeResponse/result/address_component[" & 
> I &
> "]/short_name")  into geo["State"]
>               Break
>            Case "Country"
>               put
> revxmlnodecontents(txml,"GeocodeResponse/result/address_component[" & 
> I &
> "]/long_name")  into geo["Country"]
>               Break
>            Case "postal_code"
>               put
> revxmlnodecontents(txml,"GeocodeResponse/result/address_component[" & 
> I &
> "]/long_name")  into geo["ZIP"]
>               Break
>            default
>               --breakpoint
>               break
>         end switch
>      end repeat
>      put
> revXMLChildNames(txml,"/GeocodeResponse/result/geometry",comma,,false) 
> into
> str1
>      repeat for each item nodename in str1
>         switch nodename
>            Case "location"
>               put
> revxmlnodecontents(txml,"GeocodeResponse/result/geometry/"&nodename&"/
> lat")
> into geo["Lat"]["Center"]
>               put
> revxmlnodecontents(txml,"GeocodeResponse/result/geometry/"&nodename&"/
> lng")
> into geo["Lon"]["Center"]
>               break
>            Case "location_type"
>               put
> revxmlnodecontents(txml,"GeocodeResponse/result/geometry/"&nodename)  
> into geo["LocationType"]
>               replace "RANGE_" with empty in geo["LocationType"]
>               break
>            Case "viewport"
>               put
> revXMLChildNames(txml,"/GeocodeResponse/result/geometry/"&nodename,com
> ma,,fa
> lse) into str2
>               repeat for each item vp in str2
>                  put
> revxmlnodecontents(txml,"GeocodeResponse/result/geometry/"&nodename&sl
> ash&vp
> &"/lat")  into geo["Lat"][vp]
>                  put
> revxmlnodecontents(txml,"GeocodeResponse/result/geometry/"&nodename&sl
> ash&vp
> &"/lng")  into geo["Lon"][vp]
>               end repeat
>               break
>         end switch         
>      end repeat
>   end if
>   --breakpoint
>   return geo
> end GeoCode
> 
> Ralph DiMola
> IT Director
> Evergreen Information Services
> rdimola at evergreeninfo.net
> 
> 
> -----Original Message-----
> From: use-livecode [mailto:use-livecode-bounces at lists.runrev.com] On 
> Behalf Of J. Landman Gay
> Sent: Wednesday, June 26, 2013 7:23 PM
> To: How to use LiveCode
> Subject: Re: Communicate with server using PUT
> 
> When I use the full URL with "get url" it returns a 404. When the 
> server person does it from Rails, they get data back. I need to get 
> the same data back, so I guess checking the headers won't work. The 
> server responds with stuff I need to use.
> 
> So if "get URL" is the way to do it, then the "get" should give me the
data.
> The 404 is odd, but maybe we can figure out that part.
> 
> 
> On 6/26/13 6:11 PM, Monte Goulding wrote:
>> Should be the latter... what's the error?
>> 
>> On 27/06/2013, at 9:07 AM, "J. Landman Gay" 
>> <jacque at hyperactivesw.com>
> wrote:
>> 
>>> That's an idea, thanks.
>>> 
>>> I'm having trouble actually doing the PUT. I need to send a string 
>>> like
> this:
>>> 
>>> http://domain.com/page?thing=one&other=two&somethingelse=three
>>> 
>>> What's the proper way to format that? Should I be using this:
>>> 
>>> put "thing=one&other=two&somethingelse=three" into url
> "http://domain.com/page"
>>> 
>>> Or should I use "get URL" with the full URL? Both ways are returning
> errors.
>>> 
>>> 
>>> On 6/26/13 5:53 PM, Monte Goulding wrote:
>>>> you should be able to check the libURLLastRHHeaders.. unless you 
>>>> are talking about mobile... actually there's no put on mobile anyway...
>>>> 
>>>> On 27/06/2013, at 8:48 AM, "J. Landman Gay"
>>>> <jacque at hyperactivesw.com> wrote:
>>>> 
>>>>> I need to send data to a server and they want me to use PUT 
>>>>> instead of POST. I also need to get a verification afterward to 
>>>>> know whether the transaction succeeded or not. The docs aren't 
>>>>> clear on that, it just says errors are reported in the result.
>>>>> 
>>>>> Before I spend too much time on this, does a PUT also provide a 
>>>>> response in the result?
>>> 
>>> 
>>> --
>>> Jacqueline Landman Gay         |     jacque at hyperactivesw.com
>>> HyperActive Software           |     http://www.hyperactivesw.com
>>> 
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
>> --
>> Monte Goulding
>> 
>> M E R Goulding - software development services mergExt - There's an 
>> external for that!
>> 
>> 
>> 
>> 
>> 
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
> 
> 
> -- 
> Jacqueline Landman Gay         |     jacque at hyperactivesw.com
> HyperActive Software           |     http://www.hyperactivesw.com
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list