@@ -47,7 +47,7 @@ |
||
| 47 | 47 | public function __construct($id, $secret) |
| 48 | 48 | { |
| 49 | 49 | if (!is_string($id) |
| 50 | - // Keeping this for BC. Integers greater than PHP_INT_MAX will make is_int() return false |
|
| 50 | + // Keeping this for BC. Integers greater than PHP_INT_MAX will make is_int() return false |
|
| 51 | 51 | && !is_int($id)) { |
| 52 | 52 | throw new FacebookSDKException('The "app_id" must be formatted as a string since many app ID\'s are greater than PHP_INT_MAX on some systems.'); |
| 53 | 53 | } |
@@ -602,8 +602,8 @@ |
||
| 602 | 602 | } while (!$chunk->isLastChunk()); |
| 603 | 603 | |
| 604 | 604 | return [ |
| 605 | - 'video_id' => $chunk->getVideoId(), |
|
| 606 | - 'success' => $uploader->finish($endpoint, $chunk->getUploadSessionId(), $metadata), |
|
| 605 | + 'video_id' => $chunk->getVideoId(), |
|
| 606 | + 'success' => $uploader->finish($endpoint, $chunk->getUploadSessionId(), $metadata), |
|
| 607 | 607 | ]; |
| 608 | 608 | } |
| 609 | 609 | |
@@ -1,44 +1,44 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if(!session_id()) { |
| 3 | - session_start(); |
|
| 3 | + session_start(); |
|
| 4 | 4 | } |
| 5 | 5 | require_once 'lib\Facebook\autoload.php'; |
| 6 | 6 | |
| 7 | - $appId='362540437809242'; |
|
| 8 | - $appSecret='538cd04f971479ff14dc409df2fbcf3b'; |
|
| 7 | + $appId='362540437809242'; |
|
| 8 | + $appSecret='538cd04f971479ff14dc409df2fbcf3b'; |
|
| 9 | 9 | |
| 10 | 10 | $fb = new Facebook\Facebook([ |
| 11 | - 'app_id' => $appId, // variable with My Facebook App ID |
|
| 12 | - 'app_secret' => $appSecret, |
|
| 13 | - 'default_graph_version' => 'v3.2', |
|
| 14 | - ]); |
|
| 11 | + 'app_id' => $appId, // variable with My Facebook App ID |
|
| 12 | + 'app_secret' => $appSecret, |
|
| 13 | + 'default_graph_version' => 'v3.2', |
|
| 14 | + ]); |
|
| 15 | 15 | $helper = $fb->getRedirectLoginHelper(); |
| 16 | 16 | if(isset($_GET['state'])){ |
| 17 | - $helper->getPersistentDataHandler()->set('state',$_GET['state']); |
|
| 17 | + $helper->getPersistentDataHandler()->set('state',$_GET['state']); |
|
| 18 | 18 | } |
| 19 | 19 | try { |
| 20 | - $accessToken = $helper->getAccessToken(); |
|
| 20 | + $accessToken = $helper->getAccessToken(); |
|
| 21 | 21 | } catch(Facebook\Exceptions\FacebookResponseException $e) { |
| 22 | - // When Graph returns an error |
|
| 23 | - echo 'Graph returned an error: ' . $e->getMessage(); |
|
| 24 | - exit; |
|
| 22 | + // When Graph returns an error |
|
| 23 | + echo 'Graph returned an error: ' . $e->getMessage(); |
|
| 24 | + exit; |
|
| 25 | 25 | } catch(Facebook\Exceptions\FacebookSDKException $e) { |
| 26 | - // When validation fails or other local issues |
|
| 27 | - echo 'Facebook SDK returned an error: ' . $e->getMessage(); |
|
| 28 | - exit; |
|
| 26 | + // When validation fails or other local issues |
|
| 27 | + echo 'Facebook SDK returned an error: ' . $e->getMessage(); |
|
| 28 | + exit; |
|
| 29 | 29 | } |
| 30 | 30 | if (! isset($accessToken)) { |
| 31 | - if ($helper->getError()) { |
|
| 31 | + if ($helper->getError()) { |
|
| 32 | 32 | header('HTTP/1.0 401 Unauthorized'); |
| 33 | 33 | echo "Error: " . $helper->getError() . "\n"; |
| 34 | 34 | echo "Error Code: " . $helper->getErrorCode() . "\n"; |
| 35 | 35 | echo "Error Reason: " . $helper->getErrorReason() . "\n"; |
| 36 | 36 | echo "Error Description: " . $helper->getErrorDescription() . "\n"; |
| 37 | - } else { |
|
| 37 | + } else { |
|
| 38 | 38 | header('HTTP/1.0 400 Bad Request'); |
| 39 | 39 | echo 'Bad request'; |
| 40 | - } |
|
| 41 | - exit; |
|
| 40 | + } |
|
| 41 | + exit; |
|
| 42 | 42 | } |
| 43 | 43 | // Logged in |
| 44 | 44 | //echo '<h3>Access Token</h3>'; |
@@ -55,27 +55,27 @@ discard block |
||
| 55 | 55 | //$tokenMetadata->validateUserId('123'); |
| 56 | 56 | $tokenMetadata->validateExpiration(); |
| 57 | 57 | if (! $accessToken->isLongLived()) { |
| 58 | - // Exchanges a short-lived access token for a long-lived one |
|
| 59 | - try { |
|
| 58 | + // Exchanges a short-lived access token for a long-lived one |
|
| 59 | + try { |
|
| 60 | 60 | $accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken); |
| 61 | - } catch (Facebook\Exceptions\FacebookSDKException $e) { |
|
| 61 | + } catch (Facebook\Exceptions\FacebookSDKException $e) { |
|
| 62 | 62 | echo "<p>Error getting long-lived access token: " . $e->getMessage() . "</p>\n\n"; |
| 63 | 63 | exit; |
| 64 | - } |
|
| 65 | - echo '<h3>Long-lived</h3>'; |
|
| 66 | - var_dump($accessToken->getValue()); |
|
| 64 | + } |
|
| 65 | + echo '<h3>Long-lived</h3>'; |
|
| 66 | + var_dump($accessToken->getValue()); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | $_SESSION['fb_access_token'] = (string) $accessToken; |
| 70 | 70 | try { |
| 71 | - // Returns a `Facebook\FacebookResponse` object |
|
| 72 | - $response = $fb->get('/me?fields=id,name', $accessToken); |
|
| 71 | + // Returns a `Facebook\FacebookResponse` object |
|
| 72 | + $response = $fb->get('/me?fields=id,name', $accessToken); |
|
| 73 | 73 | } catch(Facebook\Exceptions\FacebookResponseException $e) { |
| 74 | - echo 'Graph returned an error: ' . $e->getMessage(); |
|
| 75 | - exit; |
|
| 74 | + echo 'Graph returned an error: ' . $e->getMessage(); |
|
| 75 | + exit; |
|
| 76 | 76 | } catch(Facebook\Exceptions\FacebookSDKException $e) { |
| 77 | - echo 'Facebook SDK returned an error: ' . $e->getMessage(); |
|
| 78 | - exit; |
|
| 77 | + echo 'Facebook SDK returned an error: ' . $e->getMessage(); |
|
| 78 | + exit; |
|
| 79 | 79 | } |
| 80 | 80 | $user = $response->getGraphUser(); |
| 81 | 81 | |
@@ -1,18 +1,18 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | if(!session_id()) { |
| 3 | - session_start(); |
|
| 3 | + session_start(); |
|
| 4 | 4 | } |
| 5 | 5 | require_once 'lib\Facebook\autoload.php'; |
| 6 | 6 | |
| 7 | - $appId = '362540437809242'; // my facebook app id |
|
| 7 | + $appId = '362540437809242'; // my facebook app id |
|
| 8 | 8 | $appSecret = '538cd04f971479ff14dc409df2fbcf3b'; |
| 9 | 9 | $CallbackUrl = 'https://localhost/rtCamp/fb-callback.php'; |
| 10 | 10 | |
| 11 | 11 | $fb = new Facebook\Facebook([ |
| 12 | - 'app_id' => $appId, |
|
| 13 | - 'app_secret' => $appSecret, |
|
| 14 | - 'default_graph_version' => 'v3.2', |
|
| 15 | - ]); |
|
| 12 | + 'app_id' => $appId, |
|
| 13 | + 'app_secret' => $appSecret, |
|
| 14 | + 'default_graph_version' => 'v3.2', |
|
| 15 | + ]); |
|
| 16 | 16 | |
| 17 | 17 | $helper = $fb->getRedirectLoginHelper(); |
| 18 | 18 | |
@@ -2,8 +2,8 @@ discard block |
||
| 2 | 2 | require_once 'appconfig.php'; |
| 3 | 3 | |
| 4 | 4 | if(isset($_SESSION['fb_access_token'])){ |
| 5 | - // Get access token from session |
|
| 6 | - $accessToken = (string) $_SESSION['fb_access_token']; |
|
| 5 | + // Get access token from session |
|
| 6 | + $accessToken = (string) $_SESSION['fb_access_token']; |
|
| 7 | 7 | /* |
| 8 | 8 | $fb = new Facebook\Facebook([ |
| 9 | 9 | 'app_id' => $appId, |
@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | }*/ |
| 19 | 19 | echo $accessToken; |
| 20 | 20 | |
| 21 | - echo 'Welcome, ' . $user['name']; |
|
| 22 | - echo '<a href="logout.php" >Logout</a>'; |
|
| 21 | + echo 'Welcome, ' . $user['name']; |
|
| 22 | + echo '<a href="logout.php" >Logout</a>'; |
|
| 23 | 23 | |
| 24 | 24 | // Get photo albums of Facebook page using Facebook Graph API |
| 25 | 25 | $fields = "id,name,description,link,cover_photo,count"; |
@@ -57,8 +57,8 @@ discard block |
||
| 57 | 57 | } |
| 58 | 58 | //} |
| 59 | 59 | if(isset($_GET['album_id']) && isset($_GET['album_id'])){ |
| 60 | - $album_id = $_GET['album_id']; |
|
| 61 | - $album_name = $_GET['album_name']; //isset($_GET['album_name'])?:header('Location: fb-callback.php'); |
|
| 60 | + $album_id = $_GET['album_id']; |
|
| 61 | + $album_name = $_GET['album_name']; //isset($_GET['album_name'])?:header('Location: fb-callback.php'); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
@@ -113,13 +113,13 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | <div style="text-align:center"> |
| 115 | 115 | <?php |
| 116 | - if (is_array($fbPhotoData) || is_object($fbPhotoData)) |
|
| 117 | - { |
|
| 116 | + if (is_array($fbPhotoData) || is_object($fbPhotoData)) |
|
| 117 | + { |
|
| 118 | 118 | foreach($fbPhotoData as $data){ |
| 119 | - echo "<span class='dot'></span>"; |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - ?> |
|
| 119 | + echo "<span class='dot'></span>"; |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + ?> |
|
| 123 | 123 | </div> |
| 124 | 124 | |
| 125 | 125 | </div> |