Game Development Reference
In-Depth Information
Step 8 . To change the profile image, modify the Twitter Picture URL.
You can get this by browsing to the Twitter user of your choice, right-
clicking on the profile picture, selecting Open Image In New Tab or
the equivalent, and getting the image URL from the URL displayed
in the new tab.
8.5.2 Facebook
The process of user authentication with Facebook is similar to that of Twitter.
Facebook also supplies programming interfaces in C++ and C# for XCode
and Visual Studio programming.
The process of authorizing the player's account is done through a series
of Web-based calls as is the case with Twitter. Facebook, however, is a far
bigger beast and the amount of data you can obtain is very large. These
data are organized into the Facebook Graph. In brief, it is a data network
that links your own profile with that of your friends and their friends
and their friends.
Facebook, like Twitter, returns JSON-formatted data. The URLs to call to get
access to these data are documented at http://developers.facebook.com/
docs/reference/api/ . We will take a look at some of these calls and data
they return in the following workshop.
Unity Hands On
Accessing Facebook
Accessing data in Facebook requires extra code to be created that returns an
authorization number to you. This code needs to be hosted on a Web server
and registered with Facebook as a Facebook app. As this is slightly out of the
scope of this topic, we will be using one already created by Unity developer
Paul Price. The inspiration, Facebook API, and JSON code come from his Web
site at http://ifc0nfig.com/accessing-facebook-within-unity/ .
Note that this is but one way to get your Unity application to talk
to Facebook.
Step 1. Download Chapter Eight/Facebook.zip. Open the project in
Unity and select the ConnectToFacebook scene.
Step 2. Play. A small GUI box with a Connect to Facebook button will
appear in the Game, as shown in Figure 8.21 .
Step 3. Click on this button. Your browser will open. If you aren't logged
into Facebook you will be asked to do so. In the end a window with
your authentication token will appear. This is shown in Figure 8.22 .
Search Nedrilad ::




Custom Search