Java Reference
In-Depth Information
7.
Test the program. The first time you run this program, Facebook will ask you whether you want to
give your app permission. Note that the default permissions do not allow you to post through your
app. See Figure 10-25.
figure 10-25  
Next, Java will redirect you to the callback URL, which in this case is http://www
.example.com . See Figure 10-26.
Your Java program is waiting for you to provide the access token. This is the ACCESS_TOKEN_
HERE part of the callback URL: http://www.example.com/#access_token=ACCESS_TOKEN_
HERE&expires_in=NUMBER . A gain, if you open the Facebook authorization page in your Java
program (using a GUI and web browser component), you can “sniff out” this access token,
but here, just manually copy and paste it into the Eclipse console.
Next, your program will continue with requesting an app access token and verifying the
user access token with the app access token, using a similar makeRequest method as the one
you used for your Twitter client. Once this final authorization step is finished, you can exe-
cute a real request, in this case requesting some information about the user who authorized
the app (you). The final output should look like this:
Enter the access token from the callback URL:
CAAEQ89v2Cz8BAEifGHPKiaTDZCGZAf1Uf5NaODOFKrC8kL1C5iYBsY4LLCmh6J8sGTuWCMdCOP
faba9CEhJMweXofNMUp8W9skDOXGAZAimENwY3ZAebfEWx89ZAaxNCLL2PDi25X5mbUWoxD6dEiA
9fxu16iZB7EVKj4vT4uoRaV4x4tofrgUWvulVZBnsgMYZD
User access token:
Search WWH ::




Custom Search