Welcome Guest, Not a member yet? Register   Sign In
Login Question Codeigniter with Google API
#1

(This post was last modified: 05-26-2017, 02:08 PM by wolfgang1983.)

When a user logins with my google api function and is success full it adds # to the redirected controller url

I don't know how its adding the # hashtag to the redirect url I use vhost


PHP Code:
http://domain.com/usercp# 


Question is there away to stop the hashtag from showing up when user is redirect to there usercp?



PHP Code:
public function google() {
 
   $googleplus_auth $this->googleplus->getAuthenticate();
    
 
   $googleplus_info $this->googleplus->getUserInfo();

 
   $google_data = array(
    
'google_id' => $googleplus_info['id'],
    
'google_name' => $googleplus_info['name'],
    
'google_link' => $googleplus_info['link'],
    
'image' => $googleplus_info['picture'],
    
'email' => $googleplus_info['email'],
    
'firstname' => $googleplus_info['given_name'],
    
'lastname' => $googleplus_info['family_name']
 
   );

 
   $login_google_userid $this->login_model->login_with_google($googleplus_info['id'], $google_data);

 
   $_SESSION['user_id'] = $login_google_userid;

 
   redirect('usercp');




[Image: 3NmPQILJbu5E.png]

PHP Code:
<?php

defined
('BASEPATH') OR exit('No direct script access allowed');

$config['googleplus']['application_name'] = 'Some Name';
$config['googleplus']['client_id'       '********;  // Some id
$config['
googleplus']['client_secret']    = '********'; // Some secret
$config['
googleplus']['redirect_uri']     = 'http://www.mysetdomain.com/account/login/google';
$config['googleplus']['api_key'         '********'// Some api
$config['googleplus']['scopes'          = array(); 




I use this google api from here https://github.com/moemoe89/google-login-ci3

Attached Files
.php   Login.php (Size: 2.95 KB / Downloads: 164)
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#2

(05-25-2017, 11:23 PM)wolfgang1983 Wrote: When a user logins with my google api function and is success full it adds # to the redirected controller url

I don't know how its adding the # hashtag to the redirect url I use vhost


PHP Code:
http://domain.com/usercp# 


Question is there away to stop the hashtag from showing up when user is redirect to there usercp?



PHP Code:
public function google() {
 
   $googleplus_auth $this->googleplus->getAuthenticate();
    
 
   $googleplus_info $this->googleplus->getUserInfo();

 
   $google_data = array(
    
'google_id' => $googleplus_info['id'],
    
'google_name' => $googleplus_info['name'],
    
'google_link' => $googleplus_info['link'],
    
'image' => $googleplus_info['picture'],
    
'email' => $googleplus_info['email'],
    
'firstname' => $googleplus_info['given_name'],
    
'lastname' => $googleplus_info['family_name']
 
   );

 
   $login_google_userid $this->login_model->login_with_google($googleplus_info['id'], $google_data);

 
   $_SESSION['user_id'] = $login_google_userid;

 
   redirect('usercp');




I use this google api from here https://github.com/moemoe89/google-login-ci3

I always have a trailing / in the redirect- Not sure, but see that that helps your issue

PHP Code:
redirect('usercp/'); 
On the package it said needs Windows 7 or better. So I installed Linux.
Reply
#3

(05-26-2017, 01:27 AM)rtenny Wrote:
(05-25-2017, 11:23 PM)wolfgang1983 Wrote: When a user logins with my google api function and is success full it adds # to the redirected controller url

I don't know how its adding the # hashtag to the redirect url I use vhost


PHP Code:
http://domain.com/usercp# 


Question is there away to stop the hashtag from showing up when user is redirect to there usercp?



PHP Code:
public function google() {
 
   $googleplus_auth $this->googleplus->getAuthenticate();
    
 
   $googleplus_info $this->googleplus->getUserInfo();

 
   $google_data = array(
    
'google_id' => $googleplus_info['id'],
    
'google_name' => $googleplus_info['name'],
    
'google_link' => $googleplus_info['link'],
    
'image' => $googleplus_info['picture'],
    
'email' => $googleplus_info['email'],
    
'firstname' => $googleplus_info['given_name'],
    
'lastname' => $googleplus_info['family_name']
 
   );

 
   $login_google_userid $this->login_model->login_with_google($googleplus_info['id'], $google_data);

 
   $_SESSION['user_id'] = $login_google_userid;

 
   redirect('usercp');




I use this google api from here https://github.com/moemoe89/google-login-ci3

I always have a trailing / in the redirect- Not sure, but see that that helps your issue

PHP Code:
redirect('usercp/'); 

Just adds # hashtag after /#

Now very strange not sure why adds hashtag when redirect to usercp
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#4

(This post was last modified: 05-26-2017, 05:58 AM by InsiteFX.)

He's missing the single ending quote on the below...

PHP Code:
$config['googleplus']['client_id'       '********; 

Not sure if that's the full problem.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

PHP Code:
<?php

class Test extends MY_Controller
{
    public function 
__construct()
    {
        
parent::__construct();
    }

    public function 
page1() {
        echo 
'<a href="'.base_url('test/page2').'#i_like_cookies">Page 2</a>';
    }
    
    public function 
page2() {
        
redirect('test/page3'); 
    }
    
    public function 
page3() {
        echo 
'look at the url :)';
    }


@wolfgang1983 do you need an explain? Some of you links has # Tongue
Reply
#6

(05-26-2017, 05:55 AM)InsiteFX Wrote: He's missing the single ending quote on the below...

PHP Code:
$config['googleplus']['client_id'       '********; 

Not sure if that's the full problem.

I put that ******* on here because client id is private. No one else but me is to see it.
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#7

(05-26-2017, 09:04 AM)Paradinight Wrote:
PHP Code:
<?php

class Test extends MY_Controller
{
 
   public function __construct()
 
   {
 
       parent::__construct();
 
   }

 
   public function page1() {
 
       echo '<a href="'.base_url('test/page2').'#i_like_cookies">Page 2</a>';
 
   }
    
    public function 
page2() {
        
redirect('test/page3'); 
    }
    
    public function 
page3() {
        echo 
'look at the url :)';
    }


@wolfgang1983  do you need an explain? Some of you links has #  Tongue

Its some thing to do with the google api login link once success full it adds # to my http://www.example.com/usercp# my code is fine.
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#8

(05-26-2017, 05:55 AM)InsiteFX Wrote: He's missing the single ending quote on the below...

PHP Code:
$config['googleplus']['client_id'       '********; 

Not sure if that's the full problem.

I think I need to some how clean url string before I redirect so it removes # not sure how but will look into it.
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#9

(05-26-2017, 06:24 PM)wolfgang1983 Wrote:
(05-26-2017, 05:55 AM)InsiteFX Wrote: He's missing the single ending quote on the below...

PHP Code:
$config['googleplus']['client_id'       '********; 

Not sure if that's the full problem.

I think I need to some how clean url string before I redirect so it removes # not sure how but will look into it.

You use javascript for event handling. You use the link element with a hash as href?

Try on you link event code
https://api.jquery.com/event.preventdefault/
Reply
#10

I understand that, I was just pointing out that you were missing the ending closing quote.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB