I have searched online and found some info on using PHP/MySQL with Unity (like the Server Side High Scores), and several Google searches don't seem to get me closer to what I'm trying to do. Maybe I'm not quite hitting the right search terms, so I thought I'd ask here. Though I'm new to PHP, I think I have a good grasp on how the PHP scripts work on the server side.
Ultimately, I'm trying to test a proof of concept to incorporate into a project. The goal is to click a button in a web player and have it spawn a new window. The button should send two strings containing a name (e.g. John Doe) and an ID code (e.g. 12345) via a WWWForm using the $_POST command in a PHP script.
The PHP script will take the name and ID code and generate a .xfdf (XML Form Data File) via another script (createXFDF PHP script by Justin Koivisto found here if you are really interested) which combines the XFDF data with an Adobe PDF form that has 3 fields: name, ID code, and date. The date is pulled from the local system and inserted into the form while the other two should be passed as POST data. The final result is a printable certificate of completion.
I am able to spawn a new browswer tab using Application.OpenURL. I attempt to pass the name and ID code from my simple Unity project as WWWForm fields:
When I click the button in the Unity GUI, I spawn the new browser tab and start a Coroutine that waits for the WWW request:
The code above shows 12345 and the GetPDF button in a the newly created browser tab(replicated below since I don't have a URL to host images handy):
NOTE: The $name passed in the $_POST doesn't appear to be coming in.
When I look in the Unity Editor Log, I did find this:
This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.
I'm using Unity 3.4.2f3 and The Uniform Server 7.1.15-Orion (to run PHP 5.3.8 and Apache 2.2.21 as a local testing server) running on a Windows 7 Professional 64-bit system.
I have also tried my scripts on a Windows Server 2003 system running IIS 6.0 and PHP 5.3.8 since I originally had issues with permissions but I'm seeing similar results.
I thought it is a permissions issue, but I am an administrator on my system and those PHP scripts are all running on the server side. Also, just for grins, I tried passing the string "John%20Doe" as part of the URL and changed the POST to a GET. This actually echoes the string correctly and therefore correctly completes the XFDF file and resulting certificate.
So, after all that, if you are still reading, I guess the real questions are, can anyone tell me what format the AddField strings are being sent to the PHP script? Or, is the userName field always coming up blank due to the HTTP 401 error? And, why would the GET work but the POST not? Are they not subject to same/similar security constraints?
Sorry for the long post, I wanted to give sufficient background and I hope this is enough to get someone to point me in the best direction. Thanks in advance to any kind soul willing to help me.
The error probably means exactly what it says: your webserver is blocking the connection because of some permissions issue. If this is not the intended result, you should double check your webserver's configuration.
You mention you're using Apache. You may want to check
If that doesn't turn up any results, you should check your server's connection and error logs for any clues.
answered Apr 14 '12 at 03:23 AM