-2

Warning: file_get_contents(http://graph.facebook.com/) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request in /hermes/fb_youtube_downloader/redirect_url.php on line 5

Warning: Cannot modify header information - headers already sent by (output started at /hermes/bosoraweb069/b288/fb_youtube_downloader/redirect_url.php:5) in /hermes/fb_youtube_downloader/redirect_url.php on line 8 any answer will be appreciated my index.php page

 <?php session_start();
    ob_start();
    require("facebook.php");
    require("config.php");
    $facebook = new Facebook(array(
      'appId'  => $fbconfig['appid'],
      'secret' => $fbconfig['secret'],
      'cookie' => true,
      'oAuth'  => true
    )); 
    print_r($_REQUEST['arg']);
    $access         = $facebook -> getAccessToken();
    $signedRequest = $facebook ->getSignedRequest();
    /*echo "<pre>";
    print_r($signedRequest);
    echo "</pre>";
    exit;*/
    if($signedRequest['page']['id'] != ""){
      $_SESSION["fb_page_id"]    = $signedRequest['page']['id']; 
      $_SESSION['fb_page_admin'] = $signedRequest['page']['admin'];             
    }

    $loginUrl       =   $facebook->getLoginUrl(
                                            array(
                                            'scope'         => 'publish_stream,manage_pages',
                                            'redirect_uri'  => $fbconfig['redirect_uri'] . "&pageiid=".$_SESSION['fb_page_id']
                                            )
                                         );

    //$logoutUrl  = $facebook->getLogoutUrl();

    $user           =   $facebook->getUser();  # User id of the current Facebook user

    if (!$user) {
        //$_SESSION['installed'] = 1;
        echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";  # Authentication part
        exit;
    }
    ?>

my redirect url page

<?php


 if(isset($_REQUEST['page']) && $_REQUEST['page']  == "facebookPage"){
    //include("config.php");
    session_start();
    $page_details   =   file_get_contents("http://graph.facebook.com/" . $_REQUEST["pageiid"]);
    $page_arr      =    json_decode($page_details);
    $pg_url      =  $page_arr->link."?sk=app_".$_SESSION['fb_app_id'];
    header("Location: " . $pg_url);
    exit;
    }
?>

2 Answers2

0

The warning says that your problem is to get the content of the facebook page. As the warning send some strings (error message) to the display, the header() function fails.

That's not a redirect problem, but a facebook api problem (sorry, no solution from me, I dunno facebook api). May be you should change your question title.

Armage
  • 657
  • 8
  • 18
0

Confirm if you are getting $_REQUEST["pageiid"], the warning file_get_contents is because you are not providing a page or user id in the end. Like if you try going to url http://graph.facebook.com/ without a page id in the end it gives you an error, and if you specify a pageid, it works. e.g. http://graph.facebook.com/10151527552961421

So just make sure you have proper pageid in your request variable.

sven
  • 775
  • 5
  • 14