restfb: Writing a facebook application with java (using the new graph api)

后端 未结 2 485
既然无缘
既然无缘 2021-01-01 07:32

I\'m trying to write a facebook application using Java tomcat with RestFB.

the restfb documentation shows the following:

  • Create a Facebook Application<
相关标签:
2条回答
  • 2021-01-01 07:56

    As stated in the comments, these are the steps you need to take to access Facebook's graph API. However, to answer your second question:

    "How do I make sure that these steps are hidden from the user?"

    Only the first request should be performed by the user's browser. The purpose being that Facebook wants to make sure it is the sole authorization provide for the user's Facebook identity. Depending on the application you are writing, you would either use the redirect URL to point to the default redirect URL that you specified, or specify a custom url on your website that you will use to retrieve the token. The first approach is typically used by stand-alone applications such as mobile devices that can control how the browser handles redirects. The second approach would be used for a custom web-based application. Once you receive the access token, then you would perform the second operation within your code (using your favorite http apis) and not through the browser. The redirect on the access_token url is compared against the redirect url specified on the authentication-url. Facebook uses it for validation only and does not perform an actual redirect on the successful completion of the request.

    Here are the high-level steps:

    1. Redirect user's browser to the authentication-url specifying the appropriate redirect_uri
    2. Retrieve verification token from redirected browser request
    3. Perform access_token retrieval using your preferred HTTP framework (no user input required)
    4. Parse results and retrieve access token
    5. Initial restfb with token and use as needed
    0 讨论(0)
  • 2021-01-01 07:56

    The REST API has been deprecated. You should look in to the JavaScript and Graph APIs instead - there is a good article on this here: http://ocpsoft.org/opensource/creating-a-facebook-app-setup-and-tool-installation/ (Three part series, very detailed :)

    0 讨论(0)
提交回复
热议问题