[extension] faceplugs

This topic is to discuss things related to the faceplugs extension

I just added an modification and would be nice to add it to the official extension

php’s magic method to set init properties, in case you want to turn off cookies or something like that




	function __set($name,$value){

    	if(isset($this->init[$name]))

        	$this->init[$name]=$value;

    	else

        	throw new CException('Invalid init property : ' . $name);

	}

	function __get($name){

    	if(isset($this->init[$name]))

        	return $this->init[$name];

    	else

        	throw new CException('Invalid init property : ' . $name);

	}



The init properties can be changed by passing in an array to replace the defaults.

However, I can see how this is annoying when only one variable needs to be changed.

I will modify the extension to allow easier manipulation of the init variables.

Thank you for your insight.

Thanks I will contribute with more time, since I’ll be using it

specially the login/register part

Once I do more I’ll post it here

Anyway, thanks for the extension very helpful and well coded

I’ve just added the registration plugin and made it easier to change the init properties. Looking forward to your contributions :slight_smile:

Its missing a ‘div’ close tag which messes up the layout in efaceplugsbase

function run line 115 :


echo CHtml::tag('div', array('id' => 'fb-root'));

there’s no close tag for it

after


Yii::app()->params->fbRootSet = true;

add


echo CHtml::closeTag('div'); 

btw good job on the new features, Thanks!

OK, I will add an explicit close tag.

I’m working on adding asynchronous loading of the plugin and locale support, this will be released shortly.

  • v 1.3 — 2011-01-28 :[list]
  • Add asynchronous connection.
  • Add language support.
  • Add debugging option.
  • Add https support.
  • Allow init variables to be modified individually.
  • Better loading of init variables and JS.
  • Fixed div tag that was not closing

[/list]

Would you be able to show an example of the login code. I have tried this but not been able to make it work. I was able to make the like button work effectively.

thanks

The login plugin requires the facebook application ID, do you have it set ?

yes, I have the facebook appid set in config/main.php as


'params'=>array(		

      'fbAppId' => 'xxxxxxxxxxxxx'

)

and I have this for the widget in the view


$this->widget('ext.faceplugs.LoginButton', array(

		       'url' => $this->createAbsoluteUrl('/')		       

		    ));

The Login button shows on the screen, but it wont click to anywhere.

That’s really strange I have similar code and it will at least open up a popup window allowing login.




<?php $this->widget('ext.faceplugs.LoginButton'); ?>



Though passing the URL won’t hurt, it’s simply not used by the plugin.

Depending on app settings the originating page URL may not be valid but this should not stop it from allowing the user to log in.

Maybe there is something wrong with the code being generated, can you post the HTML / JS on the page ?

Mine looks like this :




<div id="fb-root"></div><fb:login-button></fb:login-button>


....


<script type="text/javascript">

/*<![CDATA[*/

window.fbAsyncInit = function(){FB.init({'status':true,'cookie':true,'xfbml':true,'appId':'xxxxxxxxxx'});};

				(function(){

				var e=document.createElement('script');

				e.async=true;

				e.src='http://connect.facebook.net/en_US/all.js';

				document.getElementById('fb-root').appendChild(e);}());

/*]]>*/

</script>



I dont have any of that code showing at all. I downloaded the latest version update where you have a text error message in in the case of no app_id and found that was coming up.

In head, when relying on Param fbAppId


<meta property="og:app_id" />

button code showing after I declare app_id locally


<fb:login-button></fb:login-button>

I inserted the app_id into the widget and the error went away, but still the button is not clickable and I dont see the js call that you have here.

I have the fbAppId set in my parameters correctly, but I notice in the EFaceplugsBase.php file that the registerOpenGraph function is called in init() on line 244 before the $this->app_id has a chance to be checked for local declaration as app_id from the widget, or if not getting fbAppId from the parameter. This is happening inside run() on line 275 after the init() has been called.


'params'=>array(				

      'fbAppId' => 'XXXXXXXXXXX',

)

So the registerOpenGraph() which makes the meta tag for app_id is called before the parameter value is passed in.

Is this correct ?

Hi ianare! Hi Gustavo!

Has any relation to the famous facebook.php with your extension.

How can I use it with db?

Where can I take user_id(from facebook to make my own userId) with your extension?

Which one have to I use <iframe> or js sdk?

What are difference of them?

Please, make me clear these!!!

Thanks!

Hi Juma

The extension is just a PHP wrapper for all facebook plugins

It uses JS SDK, and SDK creates an iframe

more about the js sdk here http://developers.fa…nce/javascript/

the app_id you must get from http://www.facebook.com/developers/

a complete documentation of each plugin can be found here http://developers.fa…m/docs/plugins/

after you get an Id you can use all plugins, including the registration one that you are more interested

To use it with DB (I suppose you mean use registration plugin and save data to db), you must define a ‘redirect_uri’ and this url defined will receive json response from facebook, to save in db just json_decode the response and save in the database

more about the registration plugin and response here http://developers.fa…s/registration/

I think that will clarify things a bit for you

thanks, Gustavo!

Sorry for taking so long to respond. A new version has been released which should fix this bug. Let me know :wink:

Hey guys, I’m sorry, but I just can’t get this extension to work and can’t figure out what the problem is.

I always get this error code:


CException


Objekt-Konfiguration muss ein Array sein, das ein "class"-Element beinhaltet.


C:\xampp\htdocs\test\protected\extensions\faceplugs\EFaceplugsBase.php(265)


253         if ($this->app_id) {

254             $this->registerOpenGraph('app_id', $this->app_id);

255         }

256 

257         foreach ($this->og as $type => $value) {

258             $this->registerOpenGraph($type, $value);

259         }

260     }

261 

262     public function run()

263     {

264         //run only once

265         if (!isset(Yii::app()->params->fbRootSet)) {

266             if ($this->debugMode === 'auto' && YII_DEBUG === true) {

267                 $this->debugMode = 'on';

268             }

269             if ($this->debugMode === 'on') {

270                 $this->scriptFile = 'static.ak.fbcdn.net/connect/en_US/core.debug.js';

271             }

272             else {

273                 $this->setScriptLocale();

274             }

275 

276             $protocol = 'http';

277             if (isset($_SERVER['HTTPS'])) {

I put the AppId in the config and in the view it looks like this:


$og = array(

    'title' => $model->translations[0]->title,

    'site_name' => 'Test',

    'description' => $model->translations[0]->description,

    'type' => 'website',

);


$this->widget('ext.faceplugs.LikeButton', array(

    'url' => $this->createAbsoluteUrl('/'),

    'og' => $og,

    'layout' => 'button_count',

    'action' => 'recommend',

    'colorscheme' => 'dark',

));

If I create a Like button directly I can get it to work … anyone got an idea for this issue? would be awesome!

hey

this looks like a bug to me

try to change the line 265 from


if (!isset(Yii::app()->params->fbRootSet)) {

to


if (!isset(Yii::app()->params['fbRootSet'])) {

or there is some error in your params config