Yii OAuth实施

Requiremen :- Yii, OAuth implemenation to authenticate and fetch user data. I found out that there are two extensions. Eauth(support OAuth 2.0 and other social networking sites) and Eoauth(OAuth 1.0). Correct me If i am wrong.

I dont have to authenticate any social networking site. It's a different url from where I need to get the data.

Now i could successfully login and authenticate using "eoauth" extension but also I need to fetch information about the user. I don't find any function or way how to fetch data from url which lies under OAuth layer. Does Eauth or Eoauth supports fetching or it has to be custom coded ? If this extensions does not do this then what is the other way I can authenticate and fetch data ?

Though Old but You just need to use CURL request to the end URL and you will get your data. I guess those modules doesn't have the function to fetch a data. I hope this might help you. I have used in one of my code and It was successful

public function GetData($url){
        $signatureMethod = new OAuthSignatureMethod_HMAC_SHA1();
        $request = OAuthRequest::from_consumer_and_token($this->consumer,$this->token, 'GET',    $url, array());
        $request->sign_request($signatureMethod, $this->consumer, $this->token);        
        $fetchUrl = $request->to_url();
        $response = Yii::app()->CURL->run($fetchUrl);     
        return json_decode($response);               
    }

Of course, Eauth supports fetching user's data. Let's see on Eauth structure. We have directories /services, /custom_services and class EOAuthService. EOAuthService contains method makeSignedRequest(), that return the protected resource from third-party site.

So, this method we can call from our serviceClass, that extends EOAuthService. For example, class FacebookOAuthService in /services directory. The class contains protected method fetchAttributes(), it calls method makeSignedRequest($url) and get $info (in JSON) from third-party site (FB in our example). Properties of this object - it's our user's data. What about /custom_services? The directory contains classes for tuning our "BaseServiceClass".

So, for example, CustomFacebookOAuthService extends FacebookOAuthService extends EOAuthService.

You need create your own class, which will make signed request for your third-party site and get proper response (in JSON, for example). Then fetch gotten info - and voila! Of course, user must be authenticated by third-party site for fine auth on your application through oauth.