Вопрос по java, facebook, offline – Facebook автономный доступ шаг за шагом

57

UPDATE: Facebook offline_access permission is being deprecated. Please refer to the official documentation for more information.
You'll have till May 1, 2012, at which date this setting will be disabled. refer to the Developer Roadmap for more info.

Error: User Rate Limit ExceededworkingError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceededhttp://www.facebook.com/authorize.php?api_key=<api-key>&v=1.0&ext_perm=offline_accessError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded Paul
Error: User Rate Limit Exceeded Henley Chiu

Ваш Ответ

6   ответов
11

offline_access

Get the offline access token

require "facebook.php";
$facebook = new Facebook(array(
    'appId'  => YOUR_APP_ID,
    'secret' => YOUR_APP_SECRET,
));

$user = $facebook->getUser();

if ($user) {
  try {
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    $user = null;
  }
}

offline_access

if (!$user) {
    $args['scope'] = 'offline_access';
    $loginUrl = $facebook->getLoginUrl($args);
}

<?php if (!$user): ?>
    <a href="<?php echo $loginUrl ?>">Login with Facebook</a>
<?php endif ?>

if ($user) {
    $token = $facebook->getAccessToken();
    // store token
}
Use the offline access token

require "facebook.php";
$facebook = new Facebook(array(
    'appId'  => YOUR_APP_ID,
    'secret' => YOUR_APP_SECRET,
));

$facebook->setAccessToken("...");

$user_profile = $facebook->api('/me');

63

create a facebook application, if you don't already have one usable for this project http://www.facebook.com/developers/apps.php#!/developers/createapp.php -- and set sandbox/developer mode on! @ Advanced Settings > Sandbox Mode > Enable (Lets only the developers of your application see it.) You'll need the Application ID (APP_ID) and Secret Key (SECRET_KEY) that are listed on your developer account summary of that application but not the old API Key.

load in your browser, already logged in to fb as the account you want your server side app to connect as, and click "allow" for the requested permissions: https://graph.facebook.com/oauth/authorize?client_id=APP_ID&scope=offline_access,read_stream&redirect_uri=http://www.facebook.com/connect/login_success.html

copy the "code" parameter from the resulting url's query string, use that in: https://graph.facebook.com/oauth/access_token?client_id=APP_ID&redirect_uri=http://www.facebook.com/connect/login_success.html&client_secret=APP_SECRET&code=CODE_FROM_2 And copy the right hand side of access_token= in the resulting page's text, which will be in the structure of: APP_ID|HEXNUM-USER_ID|WEIRD_KEY

now download either from the graph api or the classic rest api using the oath access token you just got ala (where SOURCE_ID is the facebook id for the user/group/whatever that you are looking up):

<?php
$stream = json_decode(file_get_contents("https://api.facebook.com/method/stream.get?source_ids=SOURCE_ID&access_token=ACCESS_TOKEN&format=json"));
var_dump($stream);
// this one gives a 500 internal server error from the http get if any of the fields are invalid, but only in php, not when loaded in a browser... weird.
$feed = json_decode(file_get_contents("https://graph.facebook.com/SOURCE_ID/feed?fields=id,from,created_time,link,type&access_token=ACCESS_TOKEN"));
var_dump($feed);
?>

<?php $token = explode('=', file_get_contents("https://graph.facebook.com/oauth/access_token?client_id=APP_ID&redirect_uri=http://$_SERVER[SERVER_NAME]$_SERVER[PHP_SELF]&client_secret=APP_SECRET&code=" . 
(get_magic_quotes_gpc() ? stripslashes($_GET['code']) : $_GET['code']))); 
echo $token[1]; 
// store this, the access token, in the db for the user as logged in on your site -- and don't abuse their trust! ?>

https://graph.facebook.com/oauth/authorize?client_id=APP_ID&scope=offline_access,read_stream&redirect_uri=http://www.example.com/facebook_access_token.php

0

$b=new facebook(array('appId'=>APP_ID,'secret'=>SECRET))

$facebook->getLoginUrl(array('next'=>$redirect_uri,'req_perms'=>$scope))

$session = json_decode($db->query("SELECT ..."));//get session from db $this->facebook->setSession($session);

5

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

https://www.facebook.com/dialog/oauth

Error: User Rate Limit Exceededapplication id (Error: User Rate Limit ExceededError: User Rate Limit Exceededclient_id:

https://www.facebook.com/dialog/oauth?client_id=184484190795

Error: User Rate Limit Exceededoffline_access Error: User Rate Limit ExceededError: User Rate Limit ExceededscopeError: User Rate Limit Exceeded

https://www.facebook.com/dialog/oauth?client_id=184484190795&scope=offline_access

Error: User Rate Limit Exceededredirect_uriError: User Rate Limit Exceeded

https://www.facebook.com/dialog/oauth?client_id=184484190795&scope=offline_access&redirect_uri=https%3A%2F%2Ffbrell.com%2Fecho

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit ExceededcodeError: User Rate Limit Exceededaccess_tokenError: User Rate Limit Exceeded

https://graph.facebook.com/oauth/access_token?client_id=184484190795&client_secret=XXX&code=YYY&redirect_uri=ZZZ

Error: User Rate Limit Exceededclient_idError: User Rate Limit Exceededapplication secretError: User Rate Limit Exceededclient_secretError: User Rate Limit Exceededredirect_uriError: User Rate Limit ExceededcodeError: User Rate Limit Exceededoffline_accessError: User Rate Limit Exceededaccess_tokenError: User Rate Limit Exceeded

Error: User Rate Limit Exceededoffline_accessError: User Rate Limit Exceeded

2


<a href="http://www.facebook.com/connect/prompt_permissions.php?api_key=YOUR_API_KEY&ext_perm=publish_stream%2Coffline_access&next=http%3A%2F%2Fmysite%2Ffacebookconnect&cancel=http%3A%2F%2Fmysite%2Fhome&display=wap"><img alt="Connect" src="http://static.ak.fbcdn.net/images/fbconnect/login-buttons/connect_light_medium_long.gif" id="fb_login_image"/></a>


FacebookJsonRestClient fbc = new FacebookJsonRestClient(MY_API_KEY, SECRET, sessionKey);
String auth_token = request.getParameter("auth_token");
System.out.println("infinite session kEY = " +   fbc.auth_getSession(auth_token));
3

String url="http://www.facebook.com/login.php?api_key=YOUR_API_KEY&v=1.0";
url+="&fbconnect=true&return_session=true&req_perms=offline_access,status_update";
url+="&next=http://YOUR_FaceBookCallback_SERVLET"; 
response.sendRedirect(url);
return;

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String session = request.getParameter("session");
//from this string you can obtain your infinite session_key.In order to do this, parse this string as JSON.
//Save it in the database or in the other data storage  
response.sendRedirect(ThePlaceThatYouWant);}

FacebookXmlRestClient  client = new FacebookXmlRestClient(YOUR_API_KEY, FACEBOOK_APPLICATION_SECRET,SECRET_SESSION_KEY);
client.setIsDesktop(false); 
client.users_setStatus("YourMessage");

Похожие вопросы