Accessing Google APIs via proxy

34 views
Skip to first unread message

Mike McLoughlin

unread,
Jul 6, 2011, 11:04:40 AM7/6/11
to google-app...@googlegroups.com
PHP Version 5.3.5
Zend Engine v2.3.0

I can run a simple script to log onto my Google Apps API to create users etc but I need to run this behind my College's proxy server. From behind the proxy I get a 'Unable to Connect to ssl://www.google.com:443' error message.

My original code:

<?php
set_include_path('C:\\Program Files\\Zend\\ZendServer\\GUI\\library\\');

require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Gapps');
$email = xxx';
$password = 'xxx';
$domain = xxx.ac.uk';
$service_type = Zend_Gdata_Gapps::AUTH_SERVICE_NAME;

// Instantiate a client object
$client = Zend_Gdata_ClientLogin::getHttpClient($email, $password, $service_type);

$service = new Zend_Gdata_Gapps($client, $domain);
$result = $service->retrieveUser('xxx');
print_r($result);

?>

I have tried numerous attempts to get it to work via a proxy eg

<?php
set_include_path('C:\\Program Files\\Zend\\ZendServer\\GUI\\library\\');

require_once "Zend/Http/Client/Adapter/Proxy.php";
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Gapps');
$email = 'xxx';
$password = 'xxx';
$domain = 'xxx.ac.uk';
$service_type = Zend_Gdata_Gapps::AUTH_SERVICE_NAME;

$config = array(
    'adapter'    => 'Zend_Http_Client_Adapter_Proxy',
    'proxy_host' => 'x.x.x.x',
    'proxy_port' => 8080
);

// Instantiate a client object
clientp = new Zend_Http_Client();
$clientp->setConfig($config);
$client = Zend_Gdata_ClientLogin::getHttpClient($email, $password,$service_type,$clientp);

$service = new Zend_Gdata_Gapps($client, $domain);
$result = $service->retrieveUser('xxx');
print_r($result);

?>

- this results in a Call to undefined method Zend_Http_Client::setClientLoginToken() error

My last attempts results in a server error even tho other users report using it successfully.

username = 'xxx';
$password = 'xxx';
$domain = 'xxx.ac.uk';

require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_App_HttpException');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Docs');

Zend_Loader::loadClass('Zend_Http_Client_Exception');
Zend_Loader::loadClass('Zend_Http_Client');
Zend_Loader::loadClass('Zend_Http_Client_Adapter_Proxy');

$service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;

// Configure the proxy connection
$config = array(
    'adapter'    => 'Zend_Http_Client_Adapter_Proxy',
    'proxy_host' => 'x.x.x.x',
    'proxy_port' => 8080
);

$proxiedHttpClient = new Zend_Http_Client('http://www.google.com:443', $config);


try {
  $httpClient = Zend_Gdata_ClientLogin::getHttpClient($username, $password, $service, $proxiedHttpClient);

} catch (Zend_Gdata_App_HttpException $httpException) {
  exit("An error occurred trying to connect to the proxy server\n" .        
    $httpException->getMessage() . "\n");
}

$service_go = new Zend_Gdata_Gapps($client, $domain);
$result = $service_go->retrieveUser('xxx');
print_r($result);

?>

Any help would be appreciated.

Cheers,

Mike

Michael Manoochehri

unread,
Jul 6, 2011, 1:37:43 PM7/6/11
to google-app...@googlegroups.com
Hi Mike:

First off - did you compile your PHP interpreter with OpenSSL support? Check phpinfo:

Michael

Mike McLoughlin

unread,
Jul 6, 2011, 1:44:55 PM7/6/11
to google-app...@googlegroups.com
Michael,

The crucial detail here is that all works fine with bog standard zendserver for windows installation. 

The script number 1 works and connects fine. 

Only when installed on a win Pc behind a proxy does it fail. Therefore, reasonable to assume proxy is cause. There is also a firewall but 443/ssl fine thru firewall. 

Mike

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "Google Apps Domain Information and Management APIs" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-apps-mgmt-apis/-/GSyM1bF-GvQJ.
To post to this group, send email to google-app...@googlegroups.com.
To unsubscribe from this group, send email to google-apps-mgmt...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-apps-mgmt-apis?hl=en.
Reply all
Reply to author
Forward
0 new messages