Better Facebook Syntax Error
Contents |
in the box:What's syntax error stockholm this?Security CheckThis is a standard security test that we use to prevent spammers from creating fake accounts and spamming users.SubmitEnglish (US)EspañolFrançais (France)中文(简体)العربيةPortuguês (Brasil)Italiano한국어Deutschहिन्दी日本語Sign UpLog InMessengerFacebook LiteMobileFind FriendsBadgesPeoplePagesPlacesGamesLocationsCelebritiesGroupsMomentsAboutCreate AdCreate PageDevelopersCareersPrivacyCookiesAd ChoicesTermsHelpSettingsActivity Log Facebook © 2016
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About
Club Syntax Clothing
Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up PHP Facebook SDK - syntax https://www.facebook.com/TheRealSyntaxError/ error, unexpected '[', expecting ')' [duplicate] up vote 1 down vote favorite This question already has an answer here: PHP Parse/Syntax Errors; and How to solve them? 10 answers Here is my code: $fb = new Facebook\Facebook([ 'app_id' => '1111111', // api key 'app_secret' => '22222222', // secret api key 'default_graph_version' => 'v2.5' ]); And finally I always get this error: Parse error: syntax error, unexpected http://stackoverflow.com/questions/35390146/php-facebook-sdk-syntax-error-unexpected-expecting '[', expecting ')' in... Where is a problem? php share|improve this question asked Feb 14 at 9:16 NewbieUser 367 marked as duplicate by Rizier123php Users with the php badge can single-handedly close php questions as duplicates and reopen them as needed. Feb 14 at 9:59 This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. try removing \Facebook –Richard Theobald Feb 14 at 9:16 It still get the same error. –NewbieUser Feb 14 at 9:17 1 Your php version is too old for the shortened array notation. Try this instead: $fb = new Facebook\Facebook(array(...)); –arkascha Feb 14 at 9:20 I changed it and finally I got: Fatal error: Uncaught exception 'Exception' with message 'The Facebook SDK requires PHP version 5.4 or higher.' in (...). So which Facebook SDK I should use to work with this script ?? –NewbieUser Feb 14 at 9:22 1 You should update your php version instead of ooking for an outdated SDK version. –arkascha Feb 14 at 9:32 | show 3 more comments 1 Answer 1 active
Gherkin Git Go Groovy Haml Handlebars Haskell HTML HTTP Ini iOS Jade Java Javascript jQuery JSON Julia Keyman LaTeX Linux Less LOLCODE https://codedump.io/share/P95NotkrQHIn/1/facebook-api-quot-syntax-error-unexpected-39use39-quot Makefile Markdown MATLAB MySQL NASM Node.js NSIS Objective-C Pascal Perl PHP PHP Extras PowerShell Python R React JSX reST (reStructuredText) Rip Ruby Rust SAS Sass (Sass) Sass (Scss) Scala Scheme Smalltalk Smarty SQL Stylus Swift Twig TypeScript Vb.net VHDL Wiki markup YAML Other Search Wes - 3 months ago 15x PHP Question facebook api " syntax syntax error error, unexpected 'use' " Hello I am trying to use the facebook api to verify a access token and get the user data like email etc.. However when I test it I get this Parse error: syntax error, unexpected 'use' (T_USE). Here is the code I am using currently. require_once( getcwd().'/Facebook/FacebookSession.php' );
require_once( getcwd().'/Facebook/FacebookRedirectLoginHelper.php' );
error syntax error require_once( getcwd().'/Facebook/FacebookRequest.php' );
require_once( getcwd().'/Facebook/FacebookResponse.php' );
require_once( getcwd().'/Facebook/FacebookSDKException.php' );
require_once( getcwd().'/Facebook/FacebookRequestException.php' );
require_once( getcwd().'/Facebook/FacebookAuthorizationException.php' );
require_once( getcwd().'/Facebook/GraphObject.php' );
use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;
use Facebook\GraphUser;
FacebookSession::setDefaultApplication('My App ID', 'My Secret');
// Use one of the helper classes to get a FacebookSession object.
// FacebookRedirectLoginHelper
// FacebookCanvasLoginHelper
// FacebookJavaScriptLoginHelper
// or create a FacebookSession with a valid access token:
$session = new FacebookSession('My Access Token');
try {
$me = (new FacebookRequest(
$session, 'GET', '/me'
))->execute()->getGraphObject(GraphUser::className());
echo $me->getName();
} catch (FacebookRequestException $e) {
// The Graph API returned an error
} catch (\Exception $e) {
// Some other error occurred
}
Any Ideas on how to fix this error? I never used "use" before and