[FLOW3-general] Inject Facebook-API-Object
Bernhard Marx
bernhard.marx at marxdesign.de
Thu Nov 10 09:23:57 CET 2011
Hi Christian,
thanks for your quick reply.
no problem, if I'm "successfull" I'll share...
What I posted ist the originally code from Facebook to set up the API, in "plain PHP".
How do I handle the "required_once". I had yesterday in the night the feeling that the file is not found...
Greets
Bernhard
Von: "Christian Müller (Kitsunet)"
Gesendet: Do 10.11.2011 09:11
An: flow3-general at lists.typo3.org
Betreff: Re: [FLOW3-general] Inject Facebook-API-Object
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
>
_______________________________________________
FLOW3-general mailing list
FLOW3-general at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
More information about the FLOW3-general
mailing list