- Home /
Combine OpenURL with WWW post?
I have a php page that, when called with the correct POST commands, downloads an excel spreadsheet. The trouble is, if I call it via WWW the page doesn't open, and thus the spreadsheet isn't downloaded. If I open the page via OpenURL, it doesn't receive the POST. Is there any way to combine these two functions?
If it matters, I'm using PHPExcel to generate the spreadsheet.
No way in the Unity webplayer to do like a simple HT$$anonymous$$L post form ? We need to do it with sending BinaryData ...: at the end of the application got to a blank page with POST action .. (and not sending wia httprequest and waiting for callback response )
@stephane.cottin - better to ask this as a new question rather than a comment on an old and answered question.
BI.ZONE: expert in digital risks management.
From corporations to start-ups, we help organizations around the world to develop their business safely in the digital age.
Answer by Itinerant · Mar 18, 2013 at 08:34 PM
Alright, still not quite sure how to do this, but I figure I should share my workaround for anyone who finds this. (Note that this only works if can add code to the site that the unity3d file is being hosted on, but that should be fine in most cases.)
Forget about WWW. Use Application.ExternalCall() instead. Here's how I did it:
On the html page holding the player, set up a form. Set up a hidden iframe, pointed towards the php that should accept the POST. Write a javascript function with as many arguments as you need. Have it assign the arguments to form values, then submit the form to the hidden iframe.
Now, in Unity, convert whatever data you want to POST to a string. Use Application.ExternalCall(yourJSfunction, yourdata1, yourdata2, etc) to send the information to the webpage, and have that javascript function take care of the rest. Looks like it's working pretty well.
Answer by djirving82 · Nov 14, 2019 at 05:02 AM
Sorry about the necro, but I was directed to this data, so others may see it as well. I suggest using OpenURL and adding your intended post data to the address. Then Use $_GET to grab the data from the address.
Example URL: "https://example.com/test.php?N=Thomas"
The $_GET in PHP would look like this:
$Name = ""; if(isset($_GET["N"])){ $Name = $_GET['N']; }
Then you can use the $Name variable for whatever you want in PHP