codeigniter - Fixing the Google API PHP client on hosting service -
i using google api's php client access gmail contacts. code working fine in localhost stopped working when moved hosting service. yes did verify oauth parameters , updated same in google api console too.
there way debug it? using codeigniter 2.1.
config.php -
$config['uri_protocol']= 'auto';
, in controller method addparse_str(substr(strrchr($_server['request_uri'], "?"), 1), $_get);
before if condition.then [blog][1]. config.php -
$config['uri_protocol'] = "path_info";
, controller methodparse_str($_server['query_string'], $_get);
before if condiion.
controller method
function gmail_invite() { session_start(); $gmailcontacts = array(); $client = new google_client(); $client->setapplicationname('tets'); $client->setscopes("http://www.google.com/m8/feeds/"); $client->setclientid('222222.apps.googleusercontent.com'); $client->setclientsecret('secret'); $client->setredirecturi('http://testsite.com/gmail_invite'); if (isset($_get['code'])) { $client->authenticate(); $_session['token'] = $client->getaccesstoken(); $redirect = 'http://' . $_server['http_host'] . $_server['php_self']; header('location: ' . filter_var($redirect, filter_sanitize_url)); } if (isset($_session['token'])) { $client->setaccesstoken($_session['token']); } if (isset($_request['logout'])) { unset($_session['token']); $client->revoketoken(); } if ($client->getaccesstoken()) { $req = new google_httprequest("https://www.google.com/m8/feeds/contacts/default/full?max-results=500"); $val = $client->getio()->authenticatedrequest($req); $xml = simplexml_load_string($val->getresponsebody()); $result = $xml->xpath('//gd:email'); //print "<pre>" .print_r($result,false). "</pre>"; foreach ($result $title) { array_push($gmailcontacts, mysql_real_escape_string($title->attributes()->address)); } // contacts api returns xml responses. //$response = json_encode(simplexml_load_string($val->getresponsebody())); //print "<pre>" . print_r(json_decode($response, true), true) . "</pre>"; // access token may have been updated lazily. $_session['token'] = $client->getaccesstoken(); } else { redirect($client->createauthurl()); }
config.php
<?php if ( ! defined('basepath')) exit('no direct script access allowed'); $config['base_url'] = ''; $config['index_page'] = ''; $config['uri_protocol'] = 'path_info'; $config['url_suffix'] = ''; $config['language'] = 'english'; $config['charset'] = 'utf-8'; $config['enable_hooks'] = false; $config['subclass_prefix'] = 'my_'; $config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-'; $config['allow_get_array'] = true; $config['enable_query_strings'] = false; $config['controller_trigger'] = 'c'; $config['function_trigger'] = 'm'; $config['directory_trigger'] = 'd'; // experimental not in use $config['log_threshold'] = 4; $config['log_path'] = ''; $config['log_date_format'] = 'y-m-d h:i:s'; $config['cache_path'] = ''; $config['encryption_key'] = ''; $config['sess_cookie_name'] = 'ci_session'; $config['sess_expiration'] = 7200; $config['sess_expire_on_close'] = true; $config['sess_encrypt_cookie'] = false; $config['sess_use_database'] = false; $config['sess_table_name'] = 'ci_sessions'; $config['sess_match_ip'] = false; $config['sess_match_useragent'] = true; $config['sess_time_to_update'] = 300; $config['cookie_prefix'] = ""; $config['cookie_domain'] = ""; $config['cookie_path'] = "/"; $config['cookie_secure'] = false; $config['global_xss_filtering'] = false; $config['csrf_protection'] = false; $config['csrf_token_name'] = 'csrf_test_name'; $config['csrf_cookie_name'] = 'csrf_cookie_name'; $config['csrf_expire'] = 7200; $config['compress_output'] = false; $config['time_reference'] = 'local'; $config['rewrite_short_tags'] = false; $config['proxy_ips'] = ''; /* end of file config.php */ /* location: ./application/config/config.php */
Comments
Post a Comment