使用此代码打开Facebook应用程序时,我遇到意外T_VARIABLE错误.请使此代码正确


I get unexpected T_VARIABLE error when i open facebook application with this code.Please make this code correct

  <?php
        session_start();
        require_once 'facebook.php';
        $app_id = "418907881455014";
        $app_secret = "36389d2c4caaf6de86982cb87686a494";
        $redirect_uri = 'http://gooogle12.comuf.com'
        $facebook = new Facebook(array(
                'appId' => $app_id,
                'secret' => $app_secret,
                'cookie' => true
        ));
        $user = $facebook->getUser();
        $user_profile = $facebook->api('/me');
        $coded = $_REQUEST['code'];
        $access_token = $facebook->getAccessToken();
        $name = "".$user_profile['name']."";
        $fbid = "".$user_profile['id']."";
        function RandomLine($filename) {
            $lines = file($filename) ;
            return $lines[array_rand($lines)] ;
        }
        $reason = RandomLine("reason.txt");  
        $canvas = imagecreatefromjpeg ("test3/bg.jpg");                                   // background image file
        $black = imagecolorallocate( $canvas, 0, 0, 0 );                         // The second colour - to be used for the text
        $font = "arial.ttf";                                                         // Path to the font you are going to use
        $fontsize = 20;                                                             // font size
        $birthday = "".$user_profile['birthday']."";
        $death = "- ".date('d/m/Y', strtotime( '+'.rand(0, 10000).' days'))."";
        imagettftext( $canvas, 22, -1, 110, 120, $black, $font, $name );            // name
        imagettftext( $canvas, 22, -1, 110, 170, $black, $font, $birthday );        // birthday
        imagettftext( $canvas, 22, -1, 255, 172, $black, $font, $death );           // death
        imagettftext( $canvas, 20, -1, 110, 220, $black, $font, $reason );           // reason
        imagejpeg( $canvas, "img/".$fbid.".jpg", 50 );
        $facebook->setFileUploadSupport(true);
        //Create an album
        $album_details = array(
                'message'=> 'How will you die?',
                'name'=> 'How will you die?'
        );
        $create_album = $facebook->api('/me/albums', 'post', $album_details);
        //Get album ID of the album you've just created
        $album_uid = $create_album['id'];
        //Upload a photo to album of ID...
        $file='img/'.$fbid.'.jpg'; //Example image file
        $photo_details = array( 'message'=> 'Find out here: https://www.facebook.com/pages/Fun-Land/353713864642723?sk=app_270399073027751'image' => '@' . realpath($file) );
        $upload_photo = $facebook->api('/'.$album_uid.'/photos', 'post', $photo_details);
        $upphoto = $upload_photo['id'];

        ImageDestroy( $canvas );
        header("Location: http://facebook.com".$fbid."&photoid=".$upphoto."")
        ?>

好吧,我不是程序员。所以,我不知道这段代码中的错误是什么。我已经将此索引.php脚本上传到虚拟主机,但是当我打开我的Facebook应用程序时,错误是 - 解析错误:语法错误,/home/a2424901/public_html/index.php 第 7 行的意外T_VARIABLE。请帮助我使此代码正确。

错误表示第 7 行,所以它可能在附近。

您缺少前一行(第六行)的结束分号。

$redirect_uri = 'http://gooogle12.comuf.com'

这就是为什么第 7 行上的变量出乎意料的原因。


另一方面,StackOverflow的语法突出显示提醒我注意另一个更远的问题。在这一行上:

$photo_details = array( 'message'=> 'Find...51'image' => '@'.realpath($file));

看起来您没有关闭第一个数组元素,它可能应该是这样的:

$photo_details = array( 'message'=> 'Find...51', 'image' => '@'.realpath($file));

7 行缺少分号:

    $redirect_uri = 'http://gooogle12.comuf.com'

应该是这个

    $redirect_uri = 'http://gooogle12.comuf.com';