å æ¥ãä¼æ¥ã«facebookã¢ããªã®ãµã³ãã«ãä½ã£ã¦ã¿ãã®ã§ããµã³ãã«ã®ä½ãæ¹ãç´¹ä»ã
facebookã§ã³ã³ãã³ããä½ãã«ã¯ããfacebookãã¼ã¸ãããfacebookã¢ãã¤ã«ãããfacebookã¢ããªããªã©ãããã
ä»åãPHPã§ãfacebookã¢ããªããä½æããæ¹æ³ãæ¸ãã¦ã¿ãã
ï¼ï¼ç¨æãããã®
ã»facebookã¢ã«ã¦ã³ã
facebookã®ã¦ã¼ã¶ã¼ã®ã¿ãã¢ããªãä½æåºæ¥ã
ã»ãµã¼ãã¼ï¼webãµã¼ãã¼ãå¿ è¦ã§ããã°DBï¼
ã¢ããªãåãã®ã¯ãfacebookä¸ã§ã¯ãªãèªåã®ç°å¢ã«ãªã
ï¼ï¼ç¨æããWebãµã¼ãã¼ã«ãfacebookã¢ããªãåãããã£ã¬ã¯ããªãä½æ
ãããã¥ã¡ã³ãã«ã¼ã/xxxx/ ããªã©ãwebã®å ¬éãã£ã¬ã¯ããªã§ããã°ã©ãã§ãOKã
ãã¨ã®è¨è¼ã§åãããã©ããfacebookã¢ããªãã£ã¦webã¢ããªã®ãã¨
ï¼ï¼ã¢ããªãç»é²
ã»ã¢ããªå称ç»é²
facebookã«ãã°ã¤ã³ãã¦ããhttps://developers.facebook.com/appsãã«ã¢ã¯ã»ã¹ããã
å³ä¸ã®ãCreate New Appããã¯ãªãã¯ããã¨ã以ä¸ã®ãããªç»é¢ãåºãã
ããã§ã¢ããªã±ã¼ã·ã§ã³ã®ååãç»é²ããã
â»ã¢ããªã®éçºãããã«ã¯ããæºå¸¯çªå·ãããã¯ã¬ã¸ããã«ã¼ããèªè¨¼ãå¿ è¦ããã®ç»é¢ã§ã©ã¡ãããå ¥åãã¾ãã
ã»ã»ãã¥ãªãã£èªè¨¼
ä¸ã®ç»é¢ã«ã¦ã表示ããã¦ããæåã«ã¦ã»ãã¥ãªãã£èªè¨¼ãè¡ã
ï¼ï¼ã¢ããªã®è©³ç´°è¨å®
ä¸ã®ç»é¢ã表示ãããã®ã§ãã¢ããªã®è©³ç´°æ å ±ãå ¥åããã
åé ç®ã®èª¬æã¯ä»¥ä¸ã®éãã
ã»App IDãApp Secret
facebookã¢ããªãããfacebookã©ã¤ãã©ãªã使ãããã®èªè¨¼ã«å©ç¨ããã
å¾è¿°ããPHPã®ã³ã¼ãå ã«è¨è¼ããã
ã»App Display Name
ããããä½æããã¢ããªã®å称ã
facebookã®ãã¼ã ã®å·¦å´ã«ã¢ããªã®ä¸è¦§ã表示ãããé åããããããã«è¡¨ç¤ºãããå称ã
ã»App Namespace
ããã¯ãã¢ããªã®URLãªã©ã«ä½¿ãããã
ã»Contact Email
ã¢ããªéçºè ã®Eã¡ã¼ã«ã¢ãã¬ã¹
ã»App Domain
ã¢ããªã®ãã¡ã¤ã³ã
ãï¼ï¼ãã§ç¨æãããµã¼ãã¼ã®ãã¡ã¤ã³
ã»Category
ã¢ããªãå±ããã«ãã´ãªã¼ã
ã¢ããªãã©ã®ãããªã³ã³ãã³ããã®ããã®ç»é²ã
ï¼ï¼ã¢ããªãåãURLãå ¥å
ã»App on Facebook
ä»åã¯ãããé¸ã¶ã
å®éã®ã¢ããªã±ã¼ã·ã§ã³ã¯èªèº«ã®ãµã¼ãã¼å ã§åãããã©ãfacebookå ã§åãã¦ããããã«è¦ããã
ã¤ã³ã©ã¤ã³ãã¬ã¼ã ã®å½¢ã¨ãªãã
ã»Canvas URL
ãï¼ï¼ãã§ä½æããé åã®URLãè¨è¼
ã»Secure Canvas URL
SSLã§åä½ããå ´åãSSLé åã®URLè¨è¼
ã»Canvas Page
èªåã§è¨è¼ããããããããã¢ããªã®URLã¨ãªãã
ããã¾ã§ã§ãfacebookã§ã®è¨å®ã¯çµããã
ãå¤æ´ãä¿åããæ¼ãã¦ä¿åããã
ä»åº¦ã¯å®éã«åãã¢ããªå´ã®è¨å®
ï¼ï¼facebookã©ã¤ãã©ãªããã¦ã³ãã¼ã
ã»ãhttps://developers.facebook.com/docs/ãã«ã¢ã¯ã»ã¹ãããPHP SDKããã¯ãªãã¯
ã»ãGithubãã®facebookï¼php-sdkãã¼ã¸ã«é·ç§»ããã®ã§ããDownloadsãããã©ã¤ãã©ãªä¸å¼ããã¦ã³ãã¼ã
â»ãã®ãã¼ã¸ã«ã¯ãã©ã¤ãã©ãªãç¨ãã¦åããµã³ãã«ã³ã¼ããè¨è¼ããã¦ããã®ã§åèã«åºæ¥ãã
ï¼ï¼ãã¦ã³ãã¼ããããã¡ã¤ã«ã解çããã©ã¤ãã©ãªããï¼ï¼ãã§ä½æããé åã«é ç½®
ã»ãsrcãã¨ãããã©ã«ããããã®ã§ãããé ç½®
ãããã¥ã¡ã³ãã«ã¼ã/xxxx/src ãã®ãããªæã
ï¼ï¼facebookã¢ããªãåãã
ã»ãindex.phpãã¨ãããã¡ã¤ã«ãä½æãã以ä¸ã®ã³ã¼ããè²¼ãã¤ãã¦ããããã¥ã¡ã³ãã«ã¼ã/xxxx/ãã«ç½®ã
<?php require './src/facebook.php'; $facebook = new Facebook(array('appId' => 'App IDãè¨è¼', 'secret' => 'App Secretãè¨è¼', 'cookie' => true, )); $user = $facebook->getUser(); if ($user) { try { $user_profile = $facebook->api('/me'); } catch (FacebookApiException $e) { error_log($e); $user = null; } } if ($user) { $logoutUrl = $facebook->getLogoutUrl(); } else { $loginUrl = $facebook->getLoginUrl(); } ?> <!doctype html> <html> <head> <title>moritaro test app</title> </head> <body> <h1>moritaro test app</h1> <?php if ($user): ?> <a href="<?php echo $logoutUrl; ?>">Logout</a> <?php else: ?> <div> <a href="<?php echo $loginUrl; ?>">Login with Facebook</a> </div> <?php endif ?> <?php if ($user): ?> <h3>ã¦ã¼ã¶ã¼ç»å</h3> <img src="https://graph.facebook.com/ echo $user; ?>/picture"> <h3>ã¦ã¼ã¶ã¼æ å ±ï¼objectï¼ (/me)</h3> <pre><?php print_r($user_profile); ?></pre> <?php else: ?> <strong>no data</strong> <?php endif ?> </body> </html>
ã»ã¢ããªãhttp://apps.facebook.com/xxxx/ãã«ã¢ã¯ã»ã¹
ã¢ã¯ã»ã¹ããã¦ã¼ã¶ã¼ã®ãããã£ã¼ã«æ å ±ã表示ããã¦ããã¯ãã
èªèº«ã§ã¢ã¯ã»ã¹ãã¦ããå ´åãfacebookã®ãããã£ã¼ã«ç»é¢ã®æ å ±ãåºãã
ãã®ããã«ãfacebookã¢ããªã¯ãèªèº«ãç¨æãããµã¼ãã¼ä¸ã§åãã¢ããªã±ã¼ã·ã§ã³ã§ã
facebookã®èªè¨¼ã»ã©ã¤ãã©ãªãå©ç¨ãã¦ãfacebookå ã®æ§ã ãªæ å ±ã«ã¢ã¯ã»ã¹åºæ¥ãã
Webã¢ããªã»ã³ã³ãã³ãéçºãè¡ã£ã¦ãã人ãªããå ¨ç¶é£ãããªãã
åç´ã«facebookã®ãã¬ã¼ã å ã«ããã¤ãä½ã£ã¦ãã¢ããªãå ¥ãã ãã
ãã¨ã¯ãã¢ã¤ãã¢ã¨facebookãã¼ã¿ãé§ä½¿ãã¦ã¢ããªãä½ãã°ããã
ã¾ããã¢ã¤ãã¢ãä¸çªé£ãããã©ãï½
ãåèã«ããã¦ããã ãããµã¤ãã
Facebookã¢ããªãéçºãã¦ã¿ããï¼http://socialmediaexperience.jp/2638ï¼
facebook ã¢ããªã®ä½ãæ¹ã»PHP ç·¨ï¼2010 å¹´ 10 æçï¼