I am building a library in Zend Framework to make my web app easier to work with Facebook. So far I have modified on Zend_Oauth and create my own Oauth library so it fits with Facebook Oauth Scheme and it seems everything working well just I haven’t put down any comments yet because i still investigate what I have missed so far.. (Zend_Oauth Library seems to have more functionality which I have omitted some functions because they seem not fitting with facebook Oauth such as Post Header method which I think I can only work on Get method, but I am still investigating on it…)
(more…)
Zend Framework
My note about how I test with Zend + Facebook Oauth
This is just a note for me how I test my code to retrieve Facebook Access Token though my Zend Application since Zend_OAuth is not really useful here:
class IndexController extends Zend_Controller_Action
{
const APP_ID = YOUR_APP_ID;
const APP_SECRET = YOUR APP SECRET;
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
// redirect user to authorized url. Usually you may want to make a pop up link to open this...
$this->_helper->redirector->gotoUrl(
'https://graph.facebook.com/oauth/authorize?client_id='.
self::APP_ID.
'&redirect_uri=YOUR_CALLBACK_URL');
}
public function oauthAction() {
// if succuess will get 'code' parameters
$code = $this->getRequest()->getParam('code');
if (null !== $code)
{
// This will return an access_token and expiry if success
// $content will be 'access_token=.....&expiry=.....'
$content = file_get_contents(
'https://graph.facebook.com/oauth/access_token?client_id='.
self::APP_ID.
'&redirect_uri=YOUR_CALLBACK_URL'.
'&client_secret='.self::APP_SECRET.
'&code='.$code);
//you may want to parse $content so you can retrieve access_token alone
// Simple Test to retrieve user information
$this->view->user = json_decode(
file_get_contents(
'https://graph.facebook.com/me?'.
$content));
}
else {
// Error Code to handle.. probably user not authorize
}
}
}
My view script file:
User Name: <?= $this->user->name; ?>
Just an idea. maybe should write a service to do all the procedures like Zend_Service_Twitter.
Zend Framework and jQuery Datepicker (updated)
In my last post, I showed how to use jQuery datepicker(“option”, [option | callback]) in my viewscript to add on my datepicker, so the #start_date and #end_date can interactive with each other. Today I found a better way to do that, so that I do not have to include the javascript code in my viewscript. By using Zend_Json_Expr, I can insert my code into jQueryParams. Here is my updated form, and you can see how it works.
Zend Framework and jQuery Datepicker
I am pretty new to Zend Framework, and have been reading its reference for awhile. Today I was trying to work with Zend jQuery class and playing with datepicker. My task was trying to make two datepicker start_date and end_date, and so that after choosing the start_date, end_date will began from the selected start date (which will be using the demo code from the jQuery UI demo datepicker Event Search .