脚本宝典收集整理的这篇文章主要介绍了php – 网站上的FB登录集成,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
请帮助.我是这一切的新手.
这是我正在使用的代码 –
<?PHP session_start(); require_once "C:/xampp/htdocs/uttam/src/faceBook.PHP"; $config = array( "appId" => '<removed>',"secret" => '<removed>'); $fb = new Facebook($config); $user = $fb->getUser(); ?> <htML> <head> <tITle>Hello Facebook</title> </head> <body> <?PHP if (!$user) { $params = array( "scoPE" => "read_stream,publish_stream,user_photos","redirect_uri" => 'http://localhost/uttam'); echo '<a href="' . $fb->getLoginUrl($params) . '">LOGin</a>'; } else { ?> <form action="<?PHP echo $_SERVER["PHP_SELF"];?>" method="post" enctype="multipart/form-data"> <textarea name="message" id="message" rows="2" cols="40"></textarea><br> <input type="file" name="image" id="image"><br> <input type="submit" value="Update"> </form> <?PHP // PRocess form submission if ($_SERVER["REQUEST_METHOD"] == "POST" && !empty($_POST["message"])) { if (is_uploaded_file($_FILES["image"]["tmp_name"])) { $finfo = finfo_open(FILeiNFO_MIME_TYPE); $mime = finfo_file($finfo,$_FILES["image"]["tmp_name"]); $Allowed = array("image/gif","image/jpg","image/jpeg","image/png"); // upload image if (in_array($mime,$allowed)) { $data = array( "name" => $_POST["message"],"image" => "@" . realpath($_FILES["image"]["tmp_name"])); $fb->setFileUploadSupport(true); $status = $fb->api("/me/photos","POST",$data); } } else { // update status message $data = array("message" => $_POST["message"]); $status = $fb->api("/me/Feed",$data); } } if (isset($status)) { echo "<pre>" . print_r($status,true) . "</pre>"; } } ?> </body> </html>
以上是脚本宝典为你收集整理的php – 网站上的FB登录集成全部内容,希望文章能够帮你解决php – 网站上的FB登录集成所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。