Welcome Guest, Not a member yet? Register   Sign In
Getting parameter values from a url
#1

[eluser]mulama77[/eluser]
How can i edit the code below such that when i send the request

http://localhost/myapi/oauth/authorise?r...pi/welcome

am able to print out the oauth parameter values.

Code:
class Oauth extends CI_Controller {

public function __construct()
{
     parent::__construct();
     $this->load->helper('url');
}

public function action_authorise()
{
    // Retrieve the oauth params from the user's session
    $params['client_id'] = Session::get('client_id');
    $params['state'] = Session::get('state');
    $params['redirect_uri'] = Session::get('redirect_uri');
    $params['response_type'] = Session::get('response_type');
    $params['scope'] = Session::get('scope');

    // Check that the oauth params are all present
    foreach ($params as $key=>$value) {
        if ($value === null) {
            // Throw an error because an auth param is missing - don't
            //  continue any further
        }else{
  print($value);
  }
    }
  
}
}
#2

[eluser]TheFuzzy0ne[/eluser]
Please surround your code with [code]code tags[/code]. It makes your code easier to read.
Code:
class Oauth extends CI_Controller {

    public function __construct()
    {
        parent::__construct();
        $this->load->helper(‘url’);
    }

    public function action_authorise()
    {
        // Retrieve the oauth params from the user’s session
        $params[‘client_id’] = Session::get(‘client_id’);
        $params[‘state’] = Session::get(‘state’);
        $params[‘redirect_uri’] = Session::get(‘redirect_uri’);
        $params[‘response_type’] = Session::get(‘response_type’);
        $params[‘scope’] = Session::get(‘scope’);

        // Is this what you mean?
        print_r($params);
      
        // Check that the oauth params are all present
        foreach ($params as $key=>$value) {
            if ($value === null) {
                // Throw an error because an auth param is missing - don’t
                //  continue any further
            }
        }
    }
}

If this isn't what you're after, then I'll need more details. Where are you wanting to "print out" these values? What format are you wanting them to be in?
#3

[eluser]mulama77[/eluser]
The print out format i can manage. Am testing the above code in my browser hence i just need to see the output in my browser. My main problem is that session part i.e
Code:
$params['client_id'] = Session::get('client_id');
$params['state'] = Session::get('state');
$params['redirect_uri'] = Session::get('redirect_uri');
$params['response_type'] = Session::get('response_type');
$params['scope'] = Session::get('scope');
had to be edited to
Code:
$params['client_id'] = $this->get('client_id');
$params['state'] = $this->get('state');
$params['redirect_uri'] = $this->get('redirect_uri');
$params['response_type'] = $this->get('response_type');
$params['scope'] = $this->get('scope');
and
Code:
public function action_authorise()
had to be edited to
Code:
public function authorise_get()
and this was very different from the initial authors' code in http://alexbilbie.com/2013/02/developing...on-server/
i need to be able to print out values send on the url so as to know that the initial code posted works with the presence of the session in the code before implementing it in my API
#4

[eluser]Unknown[/eluser]
hi

the development and programming are the two different things but not so much different in development we have to develop the ideas that what we have to do using programming and in the programming part we have to coding and make the program .
mpcalling.com

thanks
#5

[eluser]mulama77[/eluser]
Which php framework is known to implement codes like
Code:
Session::
in
Code:
$params['client_id'] = Session::get('client_id');
and
Code:
public function action_authorise()
in the function controllers because CI uses
Code:
public function authorise_get()


because in need to know which framework has been used in the development of this tutorial http://alexbilbie.com/2013/02/developing...on-server/
#6

[eluser]TheFuzzy0ne[/eluser]
Try [url="http://fuelphp.com/"]FuelPHP[/url].




Theme © iAndrew 2016 - Forum software by © MyBB