lang/php

facebook API Quick Guide (CodeIgniter)

C/H 2010. 10. 15. 17:02
CodeIgniter 와 <naitik@facebook.com>의 facebook.php 를 사용한 Quick Start 가이드

Quick start on new Facebook PHP SDK (IFrame based)

try {
	$this->facebook = new Facebook(
		Array(
			'appId' => $this->config->item('facebook_app_id'),
			'secret' => $this->config->item('facebook_secret_key'),
			'cookie' => true,
			'domain' => 'phpfour.com',
		)
	);

	$session = $this->facebook->getSession();

	if (!$session){
		$url = $this->facebook->getLoginUrl(array('canvas' => 1, 'fbconnect' => 0));
	}else{

		$uid = $this->facebook->getUser();
		$me = $this->facebook->api('/me');

		$updated = date("l, F j, Y", strtotime($me['updated_time']));
		echo "Hello {$me['name']}";
		echo "You last updated your profile on " . $updated;
	}
}catch (FacebookApiException $e){
	echo "Error:" . print_r($e, true);
}
반응형