gRaViTy
gRaViTy

Reputation: 3

Code runs fine on localhost but not on Facebook. Maybe because of CURL?

The following code gives fine output while running on localhost. Earlier it was giving some error related to CURL so i fixed it and now its running fine on localhost. But my app is not running on facebook.I am using HEROKU so is it having same problem of CURL?? If so than how can i fix it?? I hav even uploaded PHP SDK on heroku. My IE gives error 500 and firefox gives a blank screen.

<html>
<head>
  <title>Test</title>
</head>
<body>

<?php

include 'libs/facebook.php';
$facebook=new Facebook(array(
  'appId'=>'************',
  'secret'=>'********************',
  'cookie'=>true
  ));


 $me=null;

 if($me)
 {
  $logoutUrl=$facebook->getLogoutUrl();
  echo "<a href'$logoutUrl'>Logout</a>";
 }
 else
 {
  $loginUrl=$facebook->getLoginUrl();
  echo "<a href='$loginUrl'>Login</a>";
 }
 ?>

 </body>
 </html>

Upvotes: 0

Views: 111

Answers (1)

phwd
phwd

Reputation: 19995

The code you posted will always ask for the login url because $me will always be null.

As to the rest of the errors, try adding error reporting to the top of your file

error_reporting(E_ALL);
ini_set("display_errors", 1);

Then deploy, then run heroku logs --tail locally to see what is going on in the file.

Also place your PHP section above your HTML outside the <html> tag.

Upvotes: 1

Related Questions