views:

29

answers:

0

I am trying to incorporate the Orkut OS PHP Client into CodeIgniter as a Library, but am having no luck.

When I test the Orkut Client out on my localhost as a standalone (not inside CodeIgniter), it works fine, but when I try it as a CodeIgniter lib, I am stuck in some kind of redirect with Google (it keeps asking the user if they grant access to my app).

Has anyone else been able to possibly port this client over into codeigniter as a library?

Edit - Here is my CodeIgniter Library

<?php
    require_once "Orkut/globals.php";
    class Orkut_api {
        private $orkut;

        private $profileFields = array( 
                                        'displayName', 
                                        'currentLocation', 
                                        'thumbnailUrl', 
                                        'gender', 
                                        'name',
                                        'emails'
                                        );
        private $friendCount = 300;

        public function Orkut_api() {
            $this->orkut = new Orkut(g_orkut_consumer_key, g_orkut_consumer_secret);
        }

        public function auth() {
            try {
                $this->orkut->login();
                $this->fetchMe();
                $this->makeRequest();
            }
            catch(Exception $e) {
                $_SESSION['oauth_token']='';
                GenericError::stop(1, "Can't authenticate on Orkut");
            }
        }

        public function fetchMe() {
            // myself call
            $me = array('method' => 'people.get', 
                'params' => array('userId' => array('@me'), 'groupId' => '@self', 'fields' => $this->profileFields),
                );

            // add current user to the batch
            Orkut::addRequest($me,'self');
        }

        public function makeRequest() {
            // try to execute the request, and stop sending an error (if we get one) 
            $exec = Orkut::execute();

            if(isset($exec['scraps']['error'])) 
                    GenericError::stop(1,$exec['scraps']['error']['message']);

            $result[] = array('id'=>'0','message'=>'ok'); 
            $result[] = $exec;
            echo json_encode($result); 
        }
    }

Here is my CI Controller:

public function orkut() {
            //Testing to make sure $_GET params work in CodeIgniter
            // if(is_array($_GET) && (!empty($_GET)))
            //              exit(print_r($_GET));

            $this->load->library('orkut_api');

            if(!isset($_SESSION['oauth_token']))
                $this->orkut_api->auth();
        }

Here is the error I am getting after changing my cURL endpoints to their sandbox environment

Uncaught exception 'Exception' with message 'Error requesting oauth access token, code 400, message: signature_invalid