Re: JSON, URL-encode, and UTF-8

2015-08-21 Thread J. Landman Gay
On 8/21/2015 3:06 AM, Dave Cragg wrote: Instead of removing the httpHeaders setting, what if you set it to this? set the httpHeaders to "Content-Type: application/x-www-form-urlencoded" This is normally the default for post, but if you had set it to something else earlier, I was wondering whet

Re: JSON, URL-encode, and UTF-8

2015-08-21 Thread Peter W A Wood
Hi Charles > On 21 Aug 2015, at 16:07, Charles Warwick > wrote: > > HI Peter, > > I did some testing with Jacque and found that her LC7 was sending the wrong > content-type when posting to the PHP script. > > In case anyone is interested: > > It was using a content type of 'application/json

Re: JSON, URL-encode, and UTF-8

2015-08-21 Thread Charles Warwick
HI Peter, I did some testing with Jacque and found that her LC7 was sending the wrong content-type when posting to the PHP script. In case anyone is interested: It was using a content type of 'application/json’ which would have made sense if the PHP script was written to accept the json data d

Re: JSON, URL-encode, and UTF-8

2015-08-21 Thread Dave Cragg
> On 21 Aug 2015, at 02:27, J. Landman Gay wrote: > > On 8/20/2015 6:45 PM, Dave Cragg wrote: >> What happens if you remove the httpHeader setting and also UrlEncode >> tData? > > Still errors I'm afraid. Instead of removing the httpHeaders setting, what if you set it to this? set the httpHea

Re: JSON, URL-encode, and UTF-8

2015-08-21 Thread Peter W A Wood
> On 21 Aug 2015, at 10:59, Peter W A Wood wrote: > > Jacque > >> On 21 Aug 2015, at 10:13, J. Landman Gay > > wrote: >> >> Here's a test. This posts just fine in LC 6.x but fails in 7.0.6 and 7.1rc1. >> >> Make a field with this in it: >> >> [{"Meals":"Yes

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread Peter W A Wood
Jacque > On 21 Aug 2015, at 11:32, J. Landman Gay wrote: > > I'd thought of that too. I'll ask the PHP guy to set up an http URL. I don’t think it is a problem with HTTPS. With Google and Stack overflow’s help, I found this website - http://httpbin.org - you can send a POST request to https:/

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread J. Landman Gay
Now I don't know what to try next. :( But I appreciate your help. This is a weird one. Is your PHP script like the one Peter posted? On 8/20/2015 10:30 PM, Charles Warwick wrote: That script works here with HTTPS, I am guessing there is something else specific about the configuration. On 21

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread J. Landman Gay
On 8/20/2015 10:23 PM, Peter W A Wood wrote: Jacque This works fine in LiveCode 7.0.3. I’ll download 7.1RC1 and see if it works there too. Apart from the difference in LiveCode versions, there is one other difference that may be significant. I am using HTTP on my machine not HTTPS. There hav

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread Charles Warwick
That script works here with HTTPS, I am guessing there is something else specific about the configuration. > On 21 Aug 2015, at 1:23 pm, Peter W A Wood wrote: > > Jacque > >> >> This works fine in LiveCode 7.0.3. I’ll download 7.1RC1 and see if it works >> there too. > > Apart from the diff

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread Peter W A Wood
Jacque > > This works fine in LiveCode 7.0.3. I’ll download 7.1RC1 and see if it works > there too. Apart from the difference in LiveCode versions, there is one other difference that may be significant. I am using HTTP on my machine not HTTPS. There have been some bugs in LiveCode 7 HTTPS sup

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread Peter W A Wood
Jacque > On 21 Aug 2015, at 10:13, J. Landman Gay wrote: > > Here's a test. This posts just fine in LC 6.x but fails in 7.0.6 and 7.1rc1. > > Make a field with this in it: > > [{"Meals":"Yes","Purpose":"Business"}] > > Now put this into a button or card script: > > constant kServerURL = "h

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread Charles Warwick
If I send that to a PHP script on one of my servers, I receive the JSON data correctly from LC7 in the PHP script. I will just run it against LC6 and make sure it is identical. If you want, you can post to my PHP script and then we can see how it compares between the two versions. If it works

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread J. Landman Gay
On 8/20/2015 8:46 PM, Charles Warwick wrote: It will still be useful… what I want to look at is what headers are generated and whether or not the JSON is still correctly formatted. With a copy of the script, I should be able to tell you what is causing it to break between the versions. I have b

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread J. Landman Gay
Here's a test. This posts just fine in LC 6.x but fails in 7.0.6 and 7.1rc1. Make a field with this in it: [{"Meals":"Yes","Purpose":"Business"}] Now put this into a button or card script: constant kServerURL = "https://www.domain.com/results.php"; --### use a valid URL here command se

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread Charles Warwick
It will still be useful… what I want to look at is what headers are generated and whether or not the JSON is still correctly formatted. With a copy of the script, I should be able to tell you what is causing it to break between the versions. I have been posting JSON data to PHP in other applica

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread J. Landman Gay
On 8/20/2015 7:24 PM, Charles Warwick wrote: If you are still having issues with this, I am happy to run a packet capture against it if you give me a copy of the script… That way I can tell you what the exact difference is between what LC7 and LC6 actually post to the server… Actually, now tha

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread J. Landman Gay
On 8/20/2015 6:45 PM, Dave Cragg wrote: What happens if you remove the httpHeader setting and also UrlEncode tData? Still errors I'm afraid. Monte wrote: What happens if you comment out line 247 of revLibURL stack script? textEncode native here seems to be a rather dangerous thing to do… S

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread Charles Warwick
Encoding the = would break the POST data, as it would no longer be assigned the json data itself as a POST variable…. you only want to url encode the contents of the json variable > On 21 Aug 2015, at 11:17 am, Monte Goulding > wrote: > > >> On 21 Aug 2015, at 10:58 am, Peter W A Wood wrote

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread Monte Goulding
> On 21 Aug 2015, at 10:58 am, Peter W A Wood wrote: > > put textEncode("{ " & quote & "é" & quote & ": 1}", "UTF-8") into tJSON > put "json=" before tJSON > post URLEncode(tJSON) to URL "http://Localhost/jacque.php > " > put textDecode(it, "UTF-8”) You would want

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread Peter W A Wood
Jacque > On 21 Aug 2015, at 07:35, J. Landman Gay wrote: > > Right. Works without header in 6, fails in 7. Thanks for looking at my file. > I wonder what would happen if I use the LC 6 libURL script in LC 7. Will my > unicode go all wonky? The file I sent you is in English but most of the time

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread Charles Warwick
If you are still having issues with this, I am happy to run a packet capture against it if you give me a copy of the script… That way I can tell you what the exact difference is between what LC7 and LC6 actually post to the server… > On 21 Aug 2015, at 9:50 am, Monte Goulding > wrote: > > W

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread Monte Goulding
What happens if you comment out line 247 of revLibURL stack script? textEncode native here seems to be a rather dangerous thing to do… > On 21 Aug 2015, at 9:45 am, Dave Cragg wrote: > > >> On 21 Aug 2015, at 00:33, J. Landman Gay wrote: >> >> On 8/20/2015 6:25 PM, Peter W A Wood wrote: >>

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread Dave Cragg
> On 21 Aug 2015, at 00:33, J. Landman Gay wrote: > > On 8/20/2015 6:25 PM, Peter W A Wood wrote: > >> You’re content is no longer valid JSON once you have inserted the >> “json=“ (at the PHP developer’s request). There may be a conflict >> between the header and the actual content. What happen

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread J. Landman Gay
On 8/20/2015 6:32 PM, Monte Goulding wrote: On 21 Aug 2015, at 9:29 am, Monte Goulding wrote: That’s a good question. I can’t see anything wrong with the JSON itself after reviewing the file. Validates and formats fine in TextMate. Are you sure they want post and not get or put? Hmm… I just

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread J. Landman Gay
On 8/20/2015 6:25 PM, Peter W A Wood wrote: You’re content is no longer valid JSON once you have inserted the “json=“ (at the PHP developer’s request). There may be a conflict between the header and the actual content. What happens if you remove the line setting the httpHeaders? Thanks Peter.

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread Monte Goulding
> On 21 Aug 2015, at 9:29 am, Monte Goulding > wrote: > > That’s a good question. I can’t see anything wrong with the JSON itself after > reviewing the file. Validates and formats fine in TextMate. Are you sure they > want post and not get or put? Hmm… I just remembered you said it works in

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread Monte Goulding
> On 21 Aug 2015, at 9:25 am, Peter W A Wood wrote: > > You’re content is no longer valid JSON once you have inserted the “json=“ (at > the PHP developer’s request). There may be a conflict between the header and > the actual content. What happens if you remove the line setting the > httpHead

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread Peter W A Wood
Jacque > On 21 Aug 2015, at 05:53, J. Landman Gay wrote: > > 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 You’re content is no longer valid JSON on

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread Monte Goulding
Just before posting can you dump your tData variable into a binfile and send it to me. It's got to be something simple... Sent from my iPhone > On 21 Aug 2015, at 8:33 am, J. Landman Gay wrote: > > Thanks, but still no go. I get the same errors. > > Is anyone posting from LC 7? I also just tr

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread J. Landman Gay
Thanks, but still no go. I get the same errors. Is anyone posting from LC 7? I also just tried 7.1rc1 but it doesn't work either. On 8/20/2015 5:04 PM, Monte Goulding wrote: Is your convertToJSON function returning UTF8? I’m not sure what LC 7 does when it concatenates “json=“ to a UTF8 stri

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread J. Landman Gay
Okay, addendum: It works fine in LC 6.7.6. It fails entirely in 7.0.6. I wish I'd tried that sooner. We need 7.x because of the unicode support. On 8/20/2015 4:53 PM, J. Landman Gay wrote: I'm still struggling with this. I have a valid JSON string, verified by a web-checking site and by the PH

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread Monte Goulding
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

Re: JSON, URL-encode, and UTF-8

2015-08-20 Thread J. Landman Gay
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= 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

Re: JSON, URL-encode, and UTF-8

2015-08-17 Thread Monte Goulding
> On 18 Aug 2015, at 6:54 am, J. Landman Gay wrote: > > Thanks Monte. The JSON is created by EasyJSON from a LC array. Most of the > values in the array are in foreign languages with lots of non-ascii > characters, and those will become the values in the parameter string that I > will send in

Re: JSON, URL-encode, and UTF-8

2015-08-17 Thread J. Landman Gay
Thanks Monte. The JSON is created by EasyJSON from a LC array. Most of the values in the array are in foreign languages with lots of non-ascii characters, and those will become the values in the parameter string that I will send in a POST. It doesn't look like EasyJSON does any UTF8 encoding wh

Re: JSON, URL-encode, and UTF-8

2015-08-17 Thread Monte Goulding
I think we would need to see the API to know about the urlEncoding. Is it a parameter in your query string? If you need to urlEncode it will be the last thing you do. If you are using one of the script libraries the UTF8 encoding may be done for you. If you are using mergJSON then UTF8 encode an

JSON, URL-encode, and UTF-8

2015-08-17 Thread J. Landman Gay
I've confused myself. I need to send JSON to a server. The values will have foreign characters in them. So I think I need to use textEncode to convert it to UTF8 and also it needs to be URL encoded. Is that right? And if so, what order do I do it in? Do I URL-encode each value in the array, th