Facebook PHP SDK 5: Extending classes -


i'm newbie classes (worse namespaces, etc.) know must create facebookmyclass.php class main classes (autoload.php, facebook.php, facebookapp.php, etc.), prototype:

<?php // guess namespace facebook;  // must 'use' or extending other class(es)? // use ;  class facebookmyclass extends facebook {     // have "re-declare" parent's vars?   private $my_private_var;   public $my_public_var;   private $access_token;    // main thing, think, how class constructed    // public function __construct(array $config = []) {   public function __construct($id, $secret) {     // work? need parameters?       parent::__construct();   }    public function accessparentprotectedvars($idfanpage) {     // how can call/link facebook object/request/response?     $object = $this->get('/' . $idfanpage . '/albums?fields=name,id', $this->access_token);   }    private function gettokens($params = []) {     // code...     $this->access_token = '...';   }  } ?> 

the question is: how can extend facebook\facebook class(es)?

a namespace represents class or group of classes lives within given project.

extending class means inheriting (gaining access to) methods within scope of class.

so example, , keep in mind may need tweak this:

<?php // imports class facebook facebook namespace eg /facebook/facebook.php use facebook\facebook;  class myfacebookextension extends facebook {      function __construct(array $config = []) {         // base class requires array parameter, accept , forward it, , call parent constructor         parent::__construct($config);     }      // .. whatever methods want add .. can access facebook() methods $this->getclient() etc within class. } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -