my own Zend Facebook service

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…)

Post to Twitter Post to Plurk Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to MySpace Post to Ping.fm Post to Reddit Post to StumbleUpon

Read More

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.

Post to Twitter Post to Plurk Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to MySpace Post to Ping.fm Post to Reddit Post to StumbleUpon

Read More

Facebook-java-api – Redirect to grant authorization

Today I have been learning facebook java api. Although I have successfully created a “hello world” app, I had a hard time to figure out how to show the grant access page. I need user to grant access to the application, so I can retrieve user data. I know I just need to redirect the page, but I tried req.sendRequest(URL) does not seem working somehow.. and I found out I set the wrong content type.. opp! stupid me! but instead of using sendRequest, I used fb tag:

(more…)

Post to Twitter Post to Plurk Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to MySpace Post to Ping.fm Post to Reddit Post to StumbleUpon

Read More