<?php
class Test extends CI_Controller
{
	public $user_id;
    public function test()
    {
		parent::__construct();
		
		$this->load->model('basic');
		$this->load->library('Web_common_report');
		$this->load->library('session');
		$this->user_id=$this->session->userdata('user_id');
        set_time_limit(0);

        echo $this->user_id;
    }
	


	function x()
	{
		echo $_GET["api_key"];
		echo $_GET["domain"];
	}
	
	function index()
	{
		$key="AIzaSyCGwZ99I4ag9VNVRL44fxYB3Ir62m5l-YQ";
		$url="https://www.googleapis.com/urlshortener/v1/url?fields=analytics%2Ccreated%2Cid%2Ckind%2ClongUrl%2Cstatus&key={$key}";
		
		$long_url="http://stackoverflow.com/questions/7843406/codeigniter-how-to-catch-db-errors";
		
		$data['longUrl']=$long_url;
		$data=json_encode($data);
		
		 $headers = array("Content-type: application/json");
						
		$ch = curl_init(); 
        curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($ch,CURLOPT_POST,TRUE);
		curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
		curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
		
		
        $content = curl_exec($ch); // run the whole process
		
		$content= json_decode($content,TRUE);
		
		echo "<pre>";
			print_r($content);
		echo "</pre>";
		
        curl_close($ch);
		
	}


	public function content()
	{
		$key="AIzaSyCGwZ99I4ag9VNVRL44fxYB3Ir62m5l-YQ";
		$short_url="http://goo.gl/Je2kfn";
		$short_url_encode	= urlencode($short_url);
		
		$url="https://www.googleapis.com/urlshortener/v1/url?shortUrl={$short_url_encode}&projection=FULL&fields=analytics%2Ccreated%2Cid%2Ckind%2ClongUrl%2Cstatus&key={$key}";
		
		$ch = curl_init(); 
        curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        $content = curl_exec($ch); // run the whole process
		
		$content= json_decode($content,TRUE);
		
		echo "<pre>";
			print_r($content);
		echo "</pre>";
		
        curl_close($ch);
	}
	
	
	
	
	function google_login(){
	
		$this->load->library('Google_login');

		echo $this->google_login->set_login_button();
		
	}
	
	
	function google_login_back(){
	
		$this->load->library('Google_login');
		$info=$this->google_login->user_details();
		
		echo "<pre>";
			print_r($info);
		echo "</pre>";
		
		
	}
	
	

	
		
		
}
	



 ?>