PHP Classes

Using the class within a other framework

Recommend this page to a friend!

      PHP OAuth Library  >  PHP OAuth Library package blog  >  How to Implement a PH...  >  All threads  >  Using the class within a other framework  >  (Un) Subscribe thread alerts  
Subject:Using the class within a other framework
Summary:Feedback on the oAuth class
Messages:4
Author:peter
Date:2012-10-05 10:57:41
Update:2012-10-05 21:43:33
 

  1. Using the class within a other framework   Reply   Report abuse  
Picture of peter peter - 2012-10-05 10:57:41
First of all: a create class for using oAuth!!
I'm working on a project using Zend Framework, which requires Twitter and Facebook oAuth. But the standard oAuth from Zend class doesn't handle Facebook.

I've included your class within the structure of the project, but there are some drawbacks which doesn't fit a standard framework like Zend.

My feedback :)
- I'm missing the declaration of private/public/protected functions. There are a couple of functions that doesn't work outside of the class, for example: GetAccessTokenURL,GetRequestTokenURL, etc.

- The function GetAccessToken checks if a session has been started, but this throws a notice:
Notice: A session had already been started - ignoring session_start() in /var/www/clients/client1/web1/private/***/library/BB/Service/Oauth/Client.php on line 698

  2. Re: Using the class within a other framework   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2012-10-05 21:43:33 - In reply to message 1 from peter
This class was initially meant to work with PHP 4 to support developers that for some reason are still stuck with it, so that is why it does not use any access qualifiers in the functions and variables.

The class now requires PHP 5.2 just when it needs to encode and decode JSON messages, but as long as PHP comes with the JSON extension or there are emulation functions, it may still run in PHP 4 because nothing else requires newer PHP versions.

Anyway, the right way to study the class is using the documentation. The documentation does not document private functions and variables because you should not need to mess with them in your applications.

Everybody should read the documentation because it explains matters that are important like the fact that out of the box the class uses sessions to store and retrieve access tokens and temporary OAuth session state values.

This is not the recommended usage of the class because sessions have limited life time. You should make the values be stored in separate containers, like for instance a database.

You can do that creating a sub-class and overriding the GetAccessToken and StoreAccessToken functions. Those functions are not meant to called from outside the class, but they are documented so you know how to reimplement them in your sub-class. Just read the documentation and let me know if you have any difficulties re-implementing those functions.

  3. Re: Using the class within a other framework   Reply   Report abuse  
Picture of Prabhulal Ramesh Prabhulal Ramesh - 2014-11-20 13:07:45 - In reply to message 2 from Manuel Lemos
I am using this function but i dont know where to use or call the StoreAccessToken function , i dont know reuse the variables by fetching from database too . can u explain , i am in very need of it and urgent requirement.

  4. Re: Using the class within a other framework   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-11-20 18:18:30 - In reply to message 3 from Prabhulal Ramesh
You should not be calling the StoreAccessToken function. That function is called by the class. At most you can create a sub-class to override that function and implement new token storage method.