Created
December 2, 2011 03:21
-
-
Save mazharul/1421582 to your computer and use it in GitHub Desktop.
Revisions
-
mazharul revised this gist
Dec 2, 2011 . 1 changed file with 1 addition and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,30 +2,20 @@ session_start(); $code = $_GET["code"]; $appId = $common->getAppId(); // your app id $myUrl = $_SERVER['HTTP_REFERER']; $appSecret = $common->secret(); //your app secret if(empty($code)) { $_SESSION['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection $dialog_url = "http://www.facebook.com/dialog/oauth?client_id=" . $appId . "&redirect_uri=" . urlencode($myUrl) . "&state=" . $_SESSION['state']."&scope=email,publish_stream,user_likes"; echo("<script> top.location.href='" . $dialog_url . "'</script>"); } if($_GET['state'] == $_SESSION['state']){ $token_url = "https://graph.facebook.com/oauth/access_token?" . "client_id=" . $appId . "&redirect_uri=" . urlencode($myUrl) . "&client_secret=" . $appSecret . "&code=" . $code; $response = file_get_contents($token_url); }else{ //CSRF protection //Somebody or some file is attacking -
mazharul revised this gist
Dec 2, 2011 . 1 changed file with 19 additions and 19 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,33 +1,33 @@ <?php session_start(); $code = $_GET["code"]; $appId = $common->getAppId(); // your app id $myUrl = $_SERVER['HTTP_REFERER']; $appSecret = $common->secret(); //your app secret if(empty($code)) { $_SESSION['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection $dialog_url = "http://www.facebook.com/dialog/oauth?client_id=" . $appId . "&redirect_uri=" . urlencode($myUrl) . "&state=" . $_SESSION['state']."&scope=email,publish_stream,user_likes"; echo("<script> top.location.href='" . $dialog_url . "'</script>"); } if($_GET['state'] == $_SESSION['state']){ $token_url = "https://graph.facebook.com/oauth/access_token?" . "client_id=" . $appId . "&redirect_uri=" . urlencode($myUrl) . "&client_secret=" . $appSecret . "&code=" . $code; $response = file_get_contents($token_url); }else{ //CSRF protection //Somebody or some file is attacking } ?> -
mazharul revised this gist
Dec 2, 2011 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,10 @@ <?php session_start(); $code = $_GET["code"]; $appId = $common->getAppId(); // your app id $myUrl = $_SERVER['HTTP_REFERER']; $appSecret = $common->secret(); //your app secret if(empty($code)) { $_SESSION['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection @@ -13,7 +13,7 @@ . $appId . "&redirect_uri=" . urlencode($myUrl) . "&state=" . $_SESSION['state']."&scope=email,publish_stream,user_likes"; echo("<script> top.location.href='" . $dialog_url . "'</script>"); } if($_GET['state'] == $_SESSION['state']){ @@ -23,7 +23,7 @@ . "&client_secret=" . $appSecret . "&code=" . $code; $response = file_get_contents($token_url); }else{ -
mazharul created this gist
Dec 2, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ <?php session_start(); $code = $_GET["code"]; $appId = $common->getAppId(); $myUrl = $_SERVER['HTTP_REFERER']; $appSecret = $common->secret(); if(empty($code)) { $_SESSION['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection $dialog_url = "http://www.facebook.com/dialog/oauth?client_id=" . $appId . "&redirect_uri=" . urlencode($myUrl) . "&state=" . $_SESSION['state']."&scope=email,publish_stream,user_likes"; // echo("<script> top.location.href='" . $dialog_url . "'</script>"); } if($_GET['state'] == $_SESSION['state']){ $token_url = "https://graph.facebook.com/oauth/access_token?" . "client_id=" . $appId . "&redirect_uri=" . urlencode($myUrl) . "&client_secret=" . $appSecret . "&code=" . $code; // $response = file_get_contents($token_url); }else{ //CSRF protection //Somebody or some file is attacking } ?>