JSON, URL-encode, and UTF-8

Monte Goulding monte at sweattechnologies.com
Thu Aug 20 18:04:01 EDT 2015


Is your convertToJSON function returning UTF8? I’m not sure what LC 7 does when it concatenates “json=“ to a UTF8 string. If for example that json= is UTF16 and the rest of the data is UTF8 it’s not surprising the server is freaking out. Try:

put textEncode(“json=“,”UTF8”) before tData

> On 21 Aug 2015, at 7:53 am, J. Landman Gay <jacque at hyperactivesw.com> wrote:
> 
> I'm still struggling with this. I have a valid JSON string, verified by a web-checking site and by the PHP developer. He wants me to POST it this way:
> 
> json=<JSON string>
> 
> It doesn't work. He says the server receives it but it is not passed to the PHP script because the main parameter is empty. Here's what I do:
> 
>  set the httpHeaders to "content-type: application/json"
>  put convertToJSON() into tData -- produces valid JSON
>  put "json=" before tData
>  post tData to kServerURL
> 
> The result is empty. The developer has set up the PHP to return the values back to me for testing, but "it" is also always empty. He says this means there is no "main parameter", but he also said adding "json=" to the front would provide that, he will just grab the params from what follows.
> 
> The URL is https if that matters. I have also tried URLEncoding the JSON but it didn't help. I also tried removing the custom header.
> 
> He pointed me to this web site: <https://www.hurl.it/> When I set it to send JSON and enter the same params there, it POSTs successfully to the server.
> 
> How would you POST a JSON string to a PHP script on a secure server?
> 
> -- 
> 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





More information about the Use-livecode mailing list