Godaddy shows blank page when i use php script

Godaddy host show me black page when i use php script but i was check php is working or not using phpinfo() php is working fine but when i use other cods it will show mw only white black page

Perhaps if you show us your code… If you’re certain that PHP is running okay, then it must be your script.

login with facebook

function get_html($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
session_start();
$_SESSION[‘lastpage’] = $_SERVER[‘HTTP_REFERER’];

require_once DIR . ‘/src/Facebook/autoload.php’;
$fb = new Facebook\Facebook([
‘app_id’ => ‘xxxxxxxxxxxxxxxxx’,
‘app_secret’ => ‘xxxxxxxxxxxxxxxxxxxxxxx’,
‘default_graph_version’ => ‘v2.6’,
]);
$helper = $fb->getRedirectLoginHelper();
$permissions = [‘email,public_profile,user_friends,user_location,user_birthday’]; // optional

try {
if (isset($_SESSION[‘facebook_access_token’])) {
$accessToken = $_SESSION[‘facebook_access_token’];
} else {
$accessToken = $helper->getAccessToken();
}
} catch(Facebook\Exceptions\FacebookResponseException $e) {
// When Graph returns an error
echo 'Graph returned an error: ’ . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
// When validation fails or other local issues
echo 'Facebook SDK returned an error: ’ . $e->getMessage();
exit;
}
if (isset($accessToken)) {
if (isset($_SESSION[‘facebook_access_token’])) {
$fb->setDefaultAccessToken($_SESSION[‘facebook_access_token’]);
} else {
// getting short-lived access token
$_SESSION[‘facebook_access_token’] = (string) $accessToken;
// OAuth 2.0 client handler
$oAuth2Client = $fb->getOAuth2Client();
// Exchanges a short-lived access token for a long-lived one
$longLivedAccessToken = $oAuth2Client->getLongLivedAccessToken($_SESSION[‘facebook_access_token’]);
$_SESSION[‘facebook_access_token’] = (string) $longLivedAccessToken;
// setting default access token to be used in script
$fb->setDefaultAccessToken($_SESSION[‘facebook_access_token’]);
}
// redirect the user back to the same page if it has “code” GET variable

if($accessToken){
$graph_url ="https://graph.facebook.com/me?fields=id,first_name,name,gender,location,birthday&access_token=" . $accessToken;
$user = json_decode(get_html($graph_url));
    $id = $user->id; 
        


if (isset($_GET['code'])) {

$fileName = $_SERVER[‘DOCUMENT_ROOT’] . “/images/$id.jpg”;
if (file_exists($fileName)) {
Echo ‘’;
}else{

    echo '<script type="text/javascript">function histBack () {history.go(-2);}window.onload=histBack();</script>';
    }

//echo ‘’;
//echo ‘Login success Go Back’;
}
// getting basic info about user
try {
$profile_request = $fb->get(‘/me?fields=name,first_name,last_name,email,location,birthday’);
$profile = $profile_request->getGraphNode()->asArray();
} catch(Facebook\Exceptions\FacebookResponseException $e) {
// When Graph returns an error
echo 'Graph returned an error: ’ . $e->getMessage();
session_destroy();
// redirecting user back to app login page
header(“Location: ./”);
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
// When validation fails or other local issues
echo 'Facebook SDK returned an error: ’ . $e->getMessage();
exit;
}
//echo ‘<img src="http://graph.facebook.com/‘.$profile[‘id’].’/picture>’;
// printing $profile array on the screen which holds the basic info about user
//print_r($profile);
//echo $accessToken;
// Now you can redirect to another page and use the access token from $_SESSION[‘facebook_access_token’]
} else {
// replace your website URL same as added in the developers.facebook.com/apps e.g. if you used http instead of https and you used non-www version or www version of your website then you must add the same here
$loginUrl = $helper->getLoginUrl(‘http://funapp.megsta.com/tokenHeader.php’, $permissions);
//echo ‘Log in with Facebook!’;

}

Do you have any error reporting on? A blank page can often be an error in the script. Check the error log file.

no there is no error log my site is http://funapp.megsta.com

Do you have any error reporting?

No i don’t have

That is your problem, you need error reporting to know what is going wrong in your php script.

How tell me

i was try to show error using error_reporting( E_ALL ); but is still show blank page

Does it create an error.log file?

Unless it’s a copy/paste thing on the board, or I’m counting wrongly, there seems to be one more { than there is }

I was try to delete and re-upload cods now its working fine

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.