0

I am trying the new Facebook SDK for Unity and I would like to deploy the example included in this SDK but like I am not running any web server. I installed the Python software in the default path (C:\Python33) and the I created web.py file and saved it into the built my Unity game (where is web.unity3d file). More info here.

See I don't have a web server available part.

Since my English is not so good, I could not understand the following part:

Then (install openssl)[http://www.openssl.org/related/binaries.html] if it isn't already on your computer. In the same directory as above, generate a key file:

openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes Provide a non-blank answer to each prompt (correctness won't matter, but empty values may).

Start the server:

python web.py

For this, could anybody explain to me how I would have to do it?

Bart
  • 19,692
  • 7
  • 68
  • 77
Alejandro Castan
  • 101
  • 4
  • 13

3 Answers3

1

Facebook is providing instructions on how to deploy a simple web server locally if you don't already have one, specifically the SimpleHTTPServer one (http://docs.python.org/2/library/simplehttpserver.html). The prerequisite is to have a SSL/TLS-capable Web server. So

First Step: Allow for SSL capability by using openssl to generate a key file for use in the server. (Keep it in the same directory)

openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -node

After executing this command, a series of prompts will be asked but for the purposes of the tutorial it isn't important what the values are as long as they are non-blank

Second Step: Create a file called web.py with the following contents

import BaseHTTPServer, SimpleHTTPServer
import ssl
httpd = BaseHTTPServer.HTTPServer(('localhost', 4443), SimpleHTTPServer.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket, certfile='server.pem', server_side=True)
httpd.serve_forever()

This line

httpd = BaseHTTPServer.HTTPServer(('localhost', 4443), SimpleHTTPServer.SimpleHTTPRequestHandler),

is how the server will be presented in a browser, https://localhost:44443/, where the game object will be at https://localhost:44443/web.unity3d

This line

httpd.socket = ssl.wrap_socket (httpd.socket, certfile='server.pem', server_side=True)

sets up SSL with the server key file generated earlier with openssl

Finally httpd.serve_forever() executes the requests and deploys the server at https://localhost:44443/

Third Step: Call the program just created by executing the following command

python web.py

Fourth Step: Navigate to https://localhost:44443/web.unity3d

phwd
  • 19,975
  • 5
  • 50
  • 78
  • Sorry for my ignorance but I am new in this topic. Where I have to execute the code -openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -node. In cmd? – Alejandro Castan Sep 01 '13 at 12:02
  • I downloaded the openssl and execute its exe file and I added the command:openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -node and I got error openssl is an invalid command – Alejandro Castan Sep 01 '13 at 12:35
  • If you get an error saying openssl is an invalid command then you need to ensure that openssl is installed properly for your Windows OS – phwd Sep 01 '13 at 21:27
  • Hi phwd,sorry but I cannot understand the following: First Step:to generate a key file for use in the server. (Keep it in the same directory)for it, Which directory is it? On the other hand, I installed the Openssl in C: Python and run the openssl.exe and execute the code "openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -node" but I got that openssl is an invalid code" and the executed the same code without openssl world and seems that it generated the key file but I do not know where it save it?, for it, Could you teach me step by step about how do it? Thanks for your time – Alejandro Castan Sep 04 '13 at 08:34
  • 1
    they also got the navigate to line wrong. The facebook api is riddled with errors and issues, I'd recommend staying away from it for a couple of months until they sort out all the problems. run SSL on port 4443, not 44443 like they say on their page. As well, install python 2.7, not 3.3, they didn't clarify. I think the poster on that facebook page just copied some random instructions from the interwebs to install an ssl client on localhost without actually knowing how to do it, thus all the problems you and anyone else who tries it will have. – Ricky Sep 09 '13 at 09:40
0

Alejandro - you don't actually need to set up a localhost server, in fact, I don't recommend it unless you really want to iterate on some Facebook callbacks and you're having trouble getting them working.

Instead I would:

  • do in-editor testing just to see how things might work. The editor dialogs use fake data, but are indicative of the in-game experience.
  • push to a hosting site for live testing. e.g. use parse hosting and do 'parse deploy' to push a static file live. I can help with this if you'd like.

Thanks for checking out the SDK!

aaron
  • 1,746
  • 1
  • 13
  • 24
  • I also made a task to take these suggestions out of the docs. it isn't a terrible thing to do, but I think it just adds unnecessary confusion. – aaron Sep 03 '13 at 05:03
  • Hi aaron,First, thanks for your help. Sorry but my English is little, for it, Could you explain me step by step about how I have to do the two spets you told me?. Thanks to undertand. – Alejandro Castan Sep 04 '13 at 08:36
  • Hi Alejandro: - for in-editor testing I would just hit the 'play' button at the top of unity and then make sure that your app runs properly and that you don't get any crashes when you call into the Facebook SDK (i.e. FB.Init, FB.Login, FB.AppRequest, and FB.Feed should all be callable without crashing. They won't work though) - For live testing, I would follow the instructions here: https://www.parse.com/docs/cloud_code_guide : please message me on Facebook if you would like some help, I'd be glad to walk you through the process – aaron Sep 05 '13 at 00:32
0

you are installing the wrong python version. Use 2.7, not 3.3. 3.3 doesn't have that library.

Ricky
  • 840
  • 1
  • 8
  • 11