Help with fbaccess.php ,writes parse error
Started on the old forum in June 2012 · view the original in the archive · old links redirect here
without seeing the script its impossible to answer probably a missing ; on line 32
okay,dis is d script
**1. <?php 2. //Application Configurations $app_ id = "id131820383"; $ app_secret = "e96824203c7myap p"; 3. $site_url = "http:// busaryweb.tk/fb/ index.php" ; try {include_once "src/ facebook.php"; }catch (Exception $e) { error_log($e); } 4. // Create our application instance $facebook = new Facebook (array ( 'appId' => $app_ id,'secret' => $app_ secret,)); 5. // Get User ID 6. $user = $facebook-
getUser ();
- // We may or may not have this data based
- // on whether the user is logged in.
- // If we have a $ user id here, it means we know
- // the user is logged into
- // Facebook, but we donyt know if the access token is valid. An access
- // token is invalid if the user logged out of Facebook. if($ user){ // ==================== Single query method============= ===================== ====
- try{ //Proceed knowing you have a logged in user who's authenticated.
- $user_profile = $ facebook -> api('/me') ; }catch (FacebookApiExcepti on $e){error_log($e); $ user = NULL; }
- // ==================== Single query method ends================ ================= }
- if($user){// Get logout URL$ logoutUrl = $ facebook -> getLogoutUrl(); }else {// Get login URL $ loginUrl = $facebook
-
getLoginUrl(array ('scope' => 'read_ stream,publish_ stream, user_ birthday, user_ location, user_work_ history, user_ hometown, user_ photos', 'redirect_uri' => $site_url, )); }
- if($user){ // Proceed knowing you have a logged in user who has a valid session.
- //========= Batch requests over the Facebook Graph API using the PHP- SDK ========
- // Save your method calls into an array $queries = array (array ('method' => 'GET', 'relative_url' => '/'.$ user), array('method' => 'GET', 'relative_url' => '/'.$user.'/home? limit=50'), array ('method' => 'GET', 'relative_url' => '/'.$ user.'/friends'), array ('method' => 'GET', 'relative_url' => '/'.$ user.'/photos?limit=6') , );
- // POST your queries to the batch endpoint on the graph.
- try{$batchResponse = $facebook->api('? batch='.json_encode($ queries), 'POST'); } catch(Exception $o) {error_log($o); }
- //Return values are indexed in order of the original array, content is in ['body'] as a JSON
- //string. Decode for use as a PHP array.
- $user_info = json_ decode($ batchResponse[0] ['body'], TRUE); $ feed = json_decode($ batchResponse[1] ['body'],TRUE); $ friends_list = json_ decode($ batchResponse[2] ['body'], TRUE); $ photos= json_decode ($batchResponse[3] ['body'], TRUE);
- //========= Batch requests over the Facebook Graph API using the PHP- SDK ends =====
- // Update user's status using graph api
- if(isset($_POST ['publish'])){ try{ $ publishStream = $ facebook -> api("/$ user/feed", 'post', array('message' => 'Check out CodeLive' , 'link' =>'http:// busaryweb.tk', 'picture' => 'http://25labs.com/ images/25- labs-160-160.jpg' , 'name' => 'CodeLive', 'caption' => 'CodeLive', 'description' => 'A Technology Laboratory. Highly Recomented technology blog.' ,)); } catch (FacebookApiExcepti on $e){error_log($e); } }
- // Update user's status using graph api
- if(isset($POST ['status'])){ try{ $ statusUpdate = $ facebook -> api("/$ user/feed", 'post', array('message' => $ POST ['status'])); } catch (FacebookApiExcepti on $e){error_log($e);
- }
- }
- }
- ?>**