Facebook Graph API 를 사용하기 위한 인증 절차를 설명합
class FacebookOAuth
- __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $dummy = NULL)
- array getAccessToken($oauth_verifier = FALSE, $redirect_uri= FALSE)
Scope
- read_stream
- publish_stream
- offline_access
Code snippet
- redirect
// 변수 설정 등 $consumer_key = '[consumer key]'; $domain = 'http://' . $_SERVER['HTTP_HOST'] . '/'; // 파라미터 $args = "scope=publish_stream,offline_access" . "&client_id=" . $consumer_key . "&redirect_uri=" . $domain . '[access token 처리 url]'; // 호출 uri $uri = "https://graph.facebook.com/oauth/authorize?" . $args; // redirect header('Location: ' . $uri);
- access token
// library 로드, 변수 설정 등 require_once('./libs/facebookoauth.php'); $consumer_key = '[consumer key]'; $consumer_secret = '[consumer secret]'; // FacebookOAuth object 생성 $connection = new FacebookOAuth($consumer_key, $consumer_secret); // 토큰 수령 $access_token = $connection->getAccessToken($_REQUEST['code']); $token = $access_token['oauth_token'];
External Links
- http://developers.facebook.com/setup/ : 페이스북 API 키 발급 (어플리케이션 등록)
- http://developers.facebook.com/docs/reference/api/permissions/#extended_perms : score 목록
- http://code.google.com/p/facebook4codingeverybody/downloads/list : facebookoauth 다운로드