php - Include a class that contain use command in another class -



php - Include a class that contain use command in another class -

i have 2 php file: facebook.php (for retrieve user info ) , myclass.php provide restfull service. facebook.php

<?php require_once( '../libs/facebook/src/facebook/httpclients/facebookhttpable.php'); require_once( '../libs/facebook/src/facebook/httpclients/facebookcurl.php' ); require_once( '../libs/facebook/src/facebook/httpclients/facebookcurlhttpclient.php' ); require_once( '../libs/facebook/src/facebook/entities/accesstoken.php' ); require_once( '../libs/facebook/src/facebook/entities/signedrequest.php' ); require_once( '../libs/facebook/src/facebook/facebooksession.php' ); require_once( '../libs/facebook/src/facebook/facebookredirectloginhelper.php' ); require_once( '../libs/facebook/src/facebook/facebookrequest.php' ); require_once( '../libs/facebook/src/facebook/facebookresponse.php' ); require_once( '../libs/facebook/src/facebook/facebooksdkexception.php' ); require_once( '../libs/facebook/src/facebook/facebookrequestexception.php' ); require_once( '../libs/facebook/src/facebook/facebookotherexception.php' ); require_once( '../libs/facebook/src/facebook/facebookauthorizationexception.php' ); require_once( '../libs/facebook/src/facebook/graphobject.php' ); require_once( '../libs/facebook/src/facebook/graphsessioninfo.php' ); utilize facebook\httpclients\facebookhttpable; utilize facebook\httpclients\facebookcurl; utilize facebook\httpclients\facebookcurlhttpclient; utilize facebook\entities\accesstoken; utilize facebook\entities\signedrequest; utilize facebook\facebooksession; utilize facebook\facebookredirectloginhelper; utilize facebook\facebookrequest; utilize facebook\facebookresponse; utilize facebook\facebooksdkexception; utilize facebook\facebookrequestexception; utilize facebook\facebookotherexception; utilize facebook\facebookauthorizationexception; utilize facebook\graphobject; utilize facebook\graphsessioninfo; function getuserdata($token){ // init app app id , secret facebooksession::setdefaultapplication( fb_app_id,fb_app_secret ); // if have valid access token: $session = new facebooksession($token); // 'access-token' /* // if you're making app-level requests: $session = facebooksession::newappsession(); */ // validate session: seek { $session->validate(); } grab (facebookrequestexception $ex) { // session not valid, graph api returned exception reason. echo $ex->getmessage(); homecoming false; } grab (\exception $ex) { // graph api returned info, may mismatch current app or have expired. echo $ex->getmessage(); homecoming false; } if($session) { seek { $user_profile = (new facebookrequest( $session, 'get', '/me'))->execute()->getgraphobject()->asarray(); //(graphuser::classname()); $id = $user_profile['id']; $user_profile['image'] = 'https://graph.facebook.com/'.$id.'/picture?width=200'; // print profile info echo '<pre>' . print_r( $user_profile, 1 ) . '</pre>'; homecoming $user_profile; // print logout url using session , redirect_uri (logout.php page should destroy session) //echo '<a href="' . $helper->getlogouturl( $session, 'http://yourwebsite.com/app/logout.php' ) . '">logout</a>'; //echo "name: " . $user_profile->getname(); } catch(facebookrequestexception $e) { echo "exception occured, code: " . $e->getcode(); echo " message: " . $e->getmessage(); homecoming false; } } } ?>

and myclass.php

<?php /** * class manage user info * * * * */ class dbhandler { function __construct() { include_once '../../../include/facebook.php'; } /** * user info facebook * @param user key * @return user info if exist else false */ public function facebooksignin($token){ $fbuserdata = getuserdata($token); if($fbuserdata == false) echo 'no user found'; else print_r($fbuserdata); } } ?>

the line ( include_once '../../../include/facebook.php'; ) right because if comment out these lines of code script works

utilize facebook\entities\accesstoken; utilize facebook\entities\signedrequest; utilize facebook\facebooksession; utilize facebook\facebookredirectloginhelper; utilize facebook\facebookrequest; utilize facebook\facebookresponse; utilize facebook\facebooksdkexception; utilize facebook\facebookrequestexception; utilize facebook\facebookotherexception; utilize facebook\facebookauthorizationexception; utilize facebook\graphobject; utilize facebook\graphsessioninfo;

probably don't understand command "use" problem? give thanks attention.

i solved. problem of path , not of operator utilize

php facebook facebook-graph-api require use

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -