[MODULE] Yiiauth

I noticed I had a problem with authorizing thrue facebook, even though other providers worked perfectly fine.

Now, for some reason facebook didnt like some certificate,so I found a solution that worked for me.

in Hybridauth/Hybrid/Providers/Facebook.php

you can find on row 365 an array, curl opts. Add SSL_VERIFYPEER =>false.

public static $CURL_OPTS = array(

CURLOPT_CONNECTTIMEOUT => 10,


CURLOPT_RETURNTRANSFER => true,


CURLOPT_TIMEOUT        => 60,


CURLOPT_USERAGENT      => 'facebook-php-3.1',


CURLOPT_SSL_VERIFYPEER => false // <--- THIS I ADDED

);

I updated the method workOnUser in DefaultController

Now if a Yii user is already logged in, the provider is connected to that user.

This way a user can have multiple provider accounts connected to the same yii-user.




	public function workOnUser($provider,$provideruser){

		$social = Social::model()->find("provider='".$provider."' AND provideruser='".$provideruser."'");

		if ( $social ){

			 $user = User::model()->find("id=".$social->yiiuser);

			 return $user;

		}else{ // no user is connected to that provideruser, 

			$social = new Social; // a new relation will be needed

			$social->provider = $provider; // what provider

			$social->provideruser = $provideruser; // the unique user

			

			// if a yii-user is already logged in add the provideruser to that account

			if ( !Yii::app()->user->isGuest ){

				$social->yiiuser = Yii::app()->user->id;	

				$user = User::model()->findByPk(Yii::app()->user->id);

			}else{

			// we want to create a new user

				$user = new User;

				$user->username = $provideruser; 


				if ( $user->save() ){ //we get an user id

					$social->yiiuser = $user->id;

					}

			}

			if($social->save())

				return $user;

		}

	

	}



And sample code to put on the profile view to show the providers that is connected to that user and allow him to connect more:




<h4> By connecting a social provider to your account you can use it to login<h4>

	<?php $socials = Social::model()->findAll('yiiuser='.$model->id);

		 if($socials){

			echo "<h5>You have currently connected your account with:</h5>";

			foreach($socials as $social){

				echo "* <b>".$social->provider."</b><br/>";

			}

		 }

		$this->widget('LoginWidget');//displays the possible providers

	?>



I there an alternative to put it in vendors folder in yii application instead of the root.

Edit* Yes, just use the new path when you use requiere_once()

(like in authenticatewith action in defaultcontroller…)

But I’m working on fixing some stuff to make these things easier

Does this extension provide a way to post updates to these provider networks? E.g. can it be used to allow Facebook status updates or tweets?

Yes,its not hard at all. I’ve done a method for it that will be included in next release…

But now already you can test with $adapter->setUserStatus( ‘foo’ );

in default controller,after successful auth.

Those who has support for status updates is:




$providers = array('facebook', 'twitter', 'identica', 'linkedin', 'qq', 'sina', 'murmur', 'pixnet','plurk');



Are you missing the providers array in module file in the new update or where did you move it.

I put a check for that in the updateStatus method in Yiiauth component (inside the module).

So if you run $this->updateStatus($provider,$status); it will check if $provider is in that array you showed, if it is it will set the user status to $status. So you do not have to worry about that.

The array for providers you would like to use, is set in the config, how to configure it is shown on the hybridauth info page. i strongly recommend to read that:)

How do you download this?

Where is the download link?

For the extension page (it also contains the download link for the current release):

http://www.yiiframework.com/extension/yiiauth/

The second line is error because of the first error, and I dont know why that line would give you an error if the login works, that same Yii::app()->controller->module->config is ran on login to… hmm

Yes…that’s why i think the problem shouldn’t be there…

So weird…

Is that works on you?

Hm, I will test it. I misread your first post, didnt see what method you were using.

I dont have time for it right now, but I will probably do it tomorrow:p

Thanks so much! That’s a great great module! :D

Ah, It didnt work for me either first, I found I had typo.

At approximately line 145




public function updateStatus($provider,$status){

	$this->newAuth();

//Change to

public function updateStatus($provider,$status){

$hybridauth = $this->newAuth();



Then it should work,atleast did so for me:)

I found that typo and had corrected it yesterday…So this is not the problem…

Still give me "Trying to get property of non-object"…

Don’t know why the same method is just not working here…!!!

-.-

I think I’ve followed every instruction verbatim, but I’m afraid I’m getting this:

Error 404

The system is unable to find the requested action "authenticatewith?openid=http:".

This looks really good!

Soon I will try this out and report back. Please keep up the good work :)

I can’t seem to get this to work; after following the instructions I get:




Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in /protected/modules/yiiauth/components/Yiiauth.php on line 31

Any ideas what I’m doing wrong?

edit Ignore, it’s a fresh install and I haven’t setup the User class yet.

A few notes from me playing with this for a bit…

Be sure to extend your base controller as stated in the instructions…




class Controller extends yiiauth

and

class DefaultController extends Controller //yiiauth default controller



  • social extends Model (doesn’t exist in my case) - for most I believe this will be CActiveRecord

  • UrlFormat is assumed to be path

  • path to images assumes app is in webroot…it should prob be prefixed with Yii::app()->basePath or something to be more universal

now trying to figure out why I’m getting this error


The provider 'Facebook' is not enabled.

when using Twitter as the provider