[FLOW3-general] Inject Facebook-API-Object

"Christian Müller (Kitsunet)" christian.mueller at typo3.org
Thu Nov 10 09:11:48 CET 2011


On 09/11/11 22:36, Bernhard Marx wrote:
> Hello,
>
>
>
> how can I inject the php facebook-api in flow3?

Hello,

I would even create a separate Package "Facebook" for them and add a 
wrapper class that extends the Facebook Class. In this class' 
constructor I would use the package settings to create the config and 
call the parent constructor. That way the wrapper class constructor is 
argument free and so the class can be injected easily.

As a side note, I am not sure if

if (!session_id()) {
        session_start();
}

is a good idea. It might interfere with FLOW3 session handling at some 
point. I would ask for a FLOW3 session in your wrapper class to be sure 
that there is a session_id.

If anything is unclear, just ask.

Cheers,
Christian

>
>
>
> Facebook has 2 phpfiles with classes.
>
>
>
> require_once "base_facebook.php";
>
>
>
> /**
>
> * Extends the BaseFacebook class with the intent of using
>
> * PHP sessions to store user ids and access tokens.
>
> */
>
> class Facebook extends BaseFacebook
>
> {
>
>    /**
>
>     * Identical to the parent constructor, except that
>
>     * we start a PHP session to store the user ID and
>
>     * access token if during the course of execution
>
>     * we discover them.
>
>     *
>
>     * @param Array $config the application configuration.
>
>     * @see BaseFacebook::__construct in facebook.php
>
>     */
>
>    public function __construct($config) {
>
>      if (!session_id()) {
>
>        session_start();
>
>      }
>
>      parent::__construct($config);
>
>    }
>
> ...
>
>
>
> This is how to initalise the object in "Plain Old PHP" ;-)
>
>
>
> require_once("facebook.php");
>
>
>
>    $config = array();
>
>    $config['appId'] = 'YOUR_APP_ID';
>
>    $config['secret'] = 'YOUR_APP_SECRET';
>
>    $config['fileUpload'] = false; // optional
>
>
>
>    $facebook = new Facebook($config);
>
>
>
> Can I put the config values somewhere in the configuration?
>
>
>
> Any help appreciated
>
>
>
> Bernhard
>




More information about the FLOW3-general mailing list