{"id":2175,"date":"2012-01-28T01:03:42","date_gmt":"2012-01-27T16:03:42","guid":{"rendered":"http:\/\/apr20.net\/?p=2175"},"modified":"2012-01-28T01:03:42","modified_gmt":"2012-01-27T16:03:42","slug":"facebook%e3%82%a2%e3%83%97%e3%83%aa%e9%96%8b%e7%99%ba%e3%80%80php%e3%81%a7%e3%83%a6%e3%83%bc%e3%82%b6%e3%83%bc%e6%83%85%e5%a0%b1%e5%8f%96%e5%be%97","status":"publish","type":"post","link":"https:\/\/apr20.net\/?p=2175","title":{"rendered":"Facebook\u30a2\u30d7\u30ea\u958b\u767a\u3000PHP\u3067\u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u53d6\u5f97"},"content":{"rendered":"<p>\u4eca\u56de\u306fFacebook\u306ePHP SDK\u3092\u4f7f\u3063\u3066\u3001\u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<h3>PHP SDK\u3092\u53d6\u5f97\u30fb\u8a2d\u7f6e<\/h3>\n<p><a href=\"http:\/\/apr20.net\/wp-content\/uploads\/2012\/01\/c00d9ce89c54d6065c0c4c4c2ccadb6c.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/apr20.net\/wp-content\/uploads\/2012\/01\/c00d9ce89c54d6065c0c4c4c2ccadb6c.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2012-01-27 23.37.20\" width=\"189\" height=\"120\" class=\"alignnone size-full wp-image-2176\"><\/a><\/p>\n<p>\u307e\u305a\u3001github\u304b\u3089Facebook\u306ePHP SDK\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/github.com\/facebook\/facebook-php-sdk\" target=\"_blank\">Facebook PHP SDK<\/a><\/p>\n<p>\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u89e3\u51cd\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30d5\u30a1\u30a4\u30eb\u69cb\u6210\u306b\u306a\u3063\u3066\u3044\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p><br class=\"aloha-end-br\"><\/p>\n<p>\/examples\/<br \/>\n\/tests\/<br \/>\n\/src\/<br \/>\nchangelog.mb<br \/>\nreadme.mb<\/p>\n<p><br class=\"aloha-end-br\"><\/p>\n<p>\u3053\u306e\u4e2d\u3067\u5fc5\u8981\u306a\u306e\u306f\u3001\u300csrc\u300d\u30d5\u30a9\u30eb\u30c0\u3067\u3059\u3002<\/p>\n<p>Facebook\u30a2\u30d7\u30ea\u306e\u30ad\u30e3\u30f3\u30d0\u30b9URL\u3067\u8a2d\u5b9a\u3057\u3066\u3044\u308b\u30b5\u30fc\u30d0\u968e\u5c64\u306b\u3001src\u30d5\u30a9\u30eb\u30c0\u3068\u3053\u308c\u304b\u3089\u4f5c\u6210\u3059\u308bindex.php\u3092\u30a2\u30c3\u30d7\u3057\u307e\u3059\u3002<\/p>\n<h3>\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u3092\u8868\u793a\u3055\u305b\u308bPHP\u30d7\u30ed\u30b0\u30e9\u30e0<\/h3>\n<p>\u4ee5\u4e0b\u306e\u30bd\u30fc\u30b9\u3092index.php\u3068\u3057\u3066\u8a2d\u7f6e\u3057\u307e\u3059\u3002<br \/>\nPHP\u5185\u306e\u30b3\u30e1\u30f3\u30c8\u3067\u300c\uff0a\uff0a\uff0a\u3092\u8a18\u5165\u300d\u3068\u306a\u3063\u3066\u3044\u308b2\u30f6\u6240\u3092\u72ec\u81ea\u306eID\u306b\u5909\u66f4\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><br class=\"aloha-end-br\"><\/p>\n<p>[php]&lt;?php<\/p>\n<p>require_once(&quot;src\/facebook.php&quot;);<\/p>\n<p>$config = array();<br \/>\n\/\/\u4ee5\u4e0b\u3092\u7de8\u96c6\u3057\u3066\u30a2\u30d7\u30eaID\u3092\u8a18\u5165<br \/>\n$config[&#8216;appId&#8217;] = &#8216;YOUR_APP_ID&#8217;;<\/p>\n<p>\/\/\u4ee5\u4e0b\u3092\u7de8\u96c6\u3057\u3066\u30a2\u30d7\u30ea\u79d8\u8a23\u3092\u8a18\u5165<br \/>\n$config[&#8216;secret&#8217;] = &#8216;YOUR_APP_SECRET&#8217;;<br \/>\n$config[&#8216;fileUpload&#8217;] = false; \/\/ optional<\/p>\n<p>$facebook = new Facebook($config);<\/p>\n<p>$uid = $facebook-&amp;gt;getUser();<\/p>\n<p>if($uid){<br \/>\ntry {<br \/>\n\/\/ Proceed knowing you have a logged in user who&#8217;s authenticated.<br \/>\n$user_profile = $facebook-&amp;gt;api(&#8216;\/me&#8217;);<\/p>\n<p>} catch (FacebookApiException $e) {<br \/>\nerror_log($e);<br \/>\n$user = null;<br \/>\n}<br \/>\n}else{<br \/>\n$loginUrl = $facebook-&amp;gt;getLoginUrl();<br \/>\necho(&quot;&amp;lt;br&amp;gt;login url=&quot;.$loginUrl);<br \/>\n};<\/p>\n<p>\/\/ Get User ID<br \/>\n$user = $facebook-&amp;gt;getUser();<\/p>\n<p>\/\/ We may or may not have this data based on whether the user is logged in.<br \/>\n\/\/<br \/>\n\/\/ If we have a $user id here, it means we know the user is logged into<br \/>\n\/\/ Facebook, but we don&#8217;t know if the access token is valid. An access<br \/>\n\/\/ token is invalid if the user logged out of Facebook.<\/p>\n<p>if ($user) {<br \/>\ntry {<br \/>\n\/\/ Proceed knowing you have a logged in user who&#8217;s authenticated.<br \/>\n$user_profile = $facebook-&amp;gt;api(&#8216;\/me&#8217;);<br \/>\n} catch (FacebookApiException $e) {<br \/>\nerror_log($e);<br \/>\n$user = null;<br \/>\n}<br \/>\n}<\/p>\n<p>\/\/ Login or logout url will be needed depending on current user state.<br \/>\nif ($user) {<br \/>\n$logoutUrl = $facebook-&amp;gt;getLogoutUrl();<br \/>\n} else {<br \/>\n$loginUrl = $facebook-&amp;gt;getLoginUrl();<br \/>\n}<\/p>\n<p>\/\/ This call will always work since we are fetching public data.<br \/>\n$naitik = $facebook-&amp;gt;api(&#8216;\/naitik&#8217;);<\/p>\n<p>?&gt;<\/p>\n<p>&lt;!DOCTYPE HTML&gt;<br \/>\n&lt;html xmlns:fb=&quot;http:\/\/www.facebook.com\/2008\/fbml&quot;&gt;<br \/>\n&lt;head&gt;<br \/>\n&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text\/html; charset=UTF-8&quot;&gt;<\/p>\n<p>&lt;title&gt;php-sdk&lt;\/title&gt;<br \/>\n&lt;style&gt;<br \/>\nbody {<br \/>\nfont-family: &#8216;Lucida Grande&#8217;, Verdana, Arial, sans-serif;<br \/>\n}<br \/>\nh1 a {<br \/>\ntext-decoration: none;<br \/>\ncolor: #3b5998;<br \/>\n}<br \/>\nh1 a:hover {<br \/>\ntext-decoration: underline;<br \/>\n}<br \/>\n&lt;\/style&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body&gt;<br \/>\n&lt;h1&gt;php-sdk&lt;\/h1&gt;<\/p>\n<p>&lt;?php if ($user): ?&gt;<br \/>\n&lt;a href=&quot;&lt;?php echo $logoutUrl; ?&gt;&quot;&gt;Logout&lt;\/a&gt;<br \/>\n&lt;?php else: ?&gt;<br \/>\n&lt;div&gt;<br \/>\nLogin using OAuth 2.0 handled by the PHP SDK:<br \/>\n&lt;a href=&quot;&lt;?php echo $loginUrl; ?&gt;&quot;&gt;Login with Facebook&lt;\/a&gt;<br \/>\n&lt;\/div&gt;<br \/>\n&lt;?php endif ?&gt;<\/p>\n<p>&lt;h3&gt;PHP Session&lt;\/h3&gt;<br \/>\n&lt;pre&gt;&lt;?php print_r($_SESSION); ?&gt;&lt;\/pre&gt;<\/p>\n<p>&lt;?php if ($user): ?&gt;<br \/>\n&lt;h3&gt;You&lt;\/h3&gt;<br \/>\n&lt;img src=&quot;https:\/\/graph.facebook.com\/&lt;?php echo $user; ?&gt;\/picture&quot;&gt;<\/p>\n<p>&lt;h3&gt;Your User Object (\/me)&lt;\/h3&gt;<br \/>\n&lt;pre&gt;&lt;?php print_r($user_profile); ?&gt;&lt;\/pre&gt;<br \/>\n&lt;?php else: ?&gt;<br \/>\n&lt;strong&gt;&lt;em&gt;You are not Connected.&lt;\/em&gt;&lt;\/strong&gt;<br \/>\n&lt;?php endif ?&gt;<\/p>\n<p>&lt;h3&gt;Public profile of Naitik&lt;\/h3&gt;<br \/>\n&lt;img src=&quot;https:\/\/graph.facebook.com\/naitik\/picture&quot;&gt;<br \/>\n&lt;?php echo $naitik[&#8216;name&#8217;]; ?&gt;<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<br \/>\n[\/php]<\/p>\n<p><br class=\"aloha-end-br\"><\/p>\n<p><a href=\"https:\/\/github.com\/facebook\/php-sdk\/tree\/master\/examples\" target=\"_blank\">\u30b5\u30f3\u30d7\u30eb\u30bd\u30fc\u30b9<\/a><\/p>\n<p><br class=\"aloha-end-br\"><\/p>\n<p>\u4e0a\u8a18\u30bd\u30fc\u30b9\u306b\u3001\u3042\u306a\u305f\u306eID\u3092\u5165\u529b\u3057\u305f\u3089\u3001index.php\u3068\u3057\u3066\u3001src\u30d5\u30a9\u30eb\u30c0\u3068\u540c\u3058\u5834\u6240\uff08facebook\u30ad\u30e3\u30f3\u30d0\u30b9URL\u306e\u7b87\u6240\uff09\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u69cb\u6210\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><br class=\"aloha-end-br\"><\/p>\n<p><strong>\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u5f8c\u306e\u30b5\u30fc\u30d0\u4e0a\u306e\u30d5\u30a1\u30a4\u30eb\u69cb\u6210<\/strong><\/p>\n<p><br class=\"aloha-end-br\"><\/p>\n<p>http:\/\/your_canvas_url.com\/src\/<br \/>\nhttp:\/\/your_canvas_url.com\/index.php<\/p>\n<p><br class=\"aloha-end-br\"><\/p>\n<p>\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u304c\u5b8c\u4e86\u3057\u305f\u3089\u3001\u4ee5\u4e0b\u306eURL\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u52d5\u4f5c\u3092\u78ba\u8a8d\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><br class=\"aloha-end-br\"><\/p>\n<p>[php]<br \/>\nhttps:\/\/www.facebook.com\/dialog\/oauth?client_id=YOUR_APP_ID&amp;redirect_uri=YOUR_CANVAS_URL<\/p>\n<p>https:\/\/www.facebook.com\/dialog\/oauth?client_id=123456789&amp;redirect_uri=https:\/\/your_canvas_url.com\/<br \/>\n[\/php]<br \/>\n\u3068\u3044\u3046\u304b\u3001\u305d\u3093\u306a\u3084\u3084\u3053\u3057\u3044\u3053\u3068\u3057\u306a\u304f\u3066\u3082\u3001facebook\u958b\u767a\u8005\u306e\u30a2\u30d7\u30ea\u60c5\u5831\u306b\u8f09\u3063\u3066\u308b\u30ab\u30f3\u30d0\u30b9URL\uff08https:\/\/apps.facebook.com\/\u301c\uff09\u306b\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3089\u3044\u3044\u3088\u3046\u306a\u30fb\u30fb\u30fb\u3002<\/p>\n<p><br class=\"aloha-end-br\"><\/p>\n<p>\u6b63\u5e38\u306b\u52d5\u4f5c\u3057\u3066\u3044\u308b\u3068\u3001[id]\u3001[name]\u3001[first_name]\u3001\u3001[last_name]\u3001[link]\u3001[username]\u3001[hometown] \u3001\u306a\u3093\u304b\u304c\u914d\u5217\u306b\u5c55\u958b\u3055\u308c\u3066\u3044\u308b\u3068\u72b6\u614b\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><strong>\u30a2\u30d7\u30ea\u3092\u516c\u958b\u3057\u3066\u3044\u308b\u30b5\u30fc\u30d0\u306ecURL\u3084SSL\u306e\u8a2d\u5b9a\u306b\u3088\u3063\u3066\u306f\u3001cURL\u95a2\u4fc2\u306e\u30a8\u30e9\u30fc\u304c\u51fa\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/strong> <\/p>\n<div style=\"position: absolute; overflow: hidden; width: 2px; height: 1px; left: -288; top: -277; z-index: 177;\"><a href=\"http:\/\/raspberry-ketone.top10songschart.com\">raspberry ketones buy online<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u56de\u306fFacebook\u306ePHP SDK\u3092\u4f7f\u3063\u3066\u3001\u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002 PH&#8230;<\/p>\n","protected":false},"author":1,"featured_media":2176,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-2175","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-facebook-web"],"_links":{"self":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts\/2175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2175"}],"version-history":[{"count":0,"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts\/2175\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=\/"}],"wp:attachment":[{"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2175"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}