Hi Larry,
Thanks for your patience with this issue.
I tried running the PHP code shared earlier by you along with Ryan's
'ProxyWithCurl' Adapter on my GoDaddy hosting test account and was
able to successfully authenticate and retrieve my Google Apps user
accounts.
I have a deluxe hosting account with GoDaddy with Hosting Config
v2.0 . They do seem to have different hosting configurations for
accounts.
Here is the PHP code that worked with 'ProxyWithCurl' Adapter for
ZendGData-1.5.2:
<?php
$path = './Zend';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
$path = get_include_path();
echo "$path";
require_once "Zend/Http/Client/Adapter/ProxyWithCurl.php";
require_once "Zend/Loader.php";
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Gapps');
$email = "[EMAIL PROTECTED]";
$password = "password";
$domain = "example.com";
$service = Zend_Gdata_Gapps::AUTH_SERVICE_NAME;
$config = array(
'adapter' =>
'Zend_Http_Client_Adapter_ProxyWithCurl',
'proxy_host' => 'proxy.shr.secureserver.net',
'proxy_port' => 3128
);
// Instantiate a client object
$clientp = new Zend_Http_Client();
$clientp->setConfig($config);
$client = Zend_Gdata_ClientLogin::getHttpClient($email, $password,
$service,$clientp);
echo "connected";
$service = new Zend_Gdata_Gapps($client, $domain);
$feed = $service->retrieveAllUsers();
$html = true;
if ($html) {echo "<h2>Registered Users</h2>\n";}
if ($html) {echo "<ul>\n";}
foreach ($feed as $user) {
if ($html) {
echo " <li>";
} else {
echo " * ";
}
echo $user->login->username . ' (';
if ($html) {
echo htmlspecialchars($user->name->givenName . ' ' .
$user->name->familyName);
} else {
echo $user->name->givenName . ' ' . $user->name-
>familyName;
}
echo ')';
if ($html) {echo '</li>';}
echo "\n";
}
if ($html) {echo "</ul>\n";}
I am also appending the 'ProxyWithCurl' Adapter for your reference:
class Zend_Http_Client_Adapter_ProxyWithCurl extends
Zend_Http_Client_Adapter_Socket
{
protected $config = array(
'ssltransport' => 'ssl',
'proxy_host' => '',
'proxy_port' => 8080,
'proxy_user' => '',
'proxy_pass' => '',
'proxy_auth' => Zend_Http_Client::AUTH_BASIC
);
public function connect($host, $port = 80, $secure = false)
{
// If no proxy is set, fall back to Socket adapter
if (! $this->config['proxy_host']) {
return parent::connect($host, $port, $secure);
}
}
public function write($method, $uri, $http_ver = '1.1', $headers
= array(), $body = '')
{
// If no proxy is set, fall back to default Socket adapter
if (! $this->config['proxy_host']) {
return parent::write($method, $uri, $http_ver, $headers,
$body);
}
$host = $this->config['proxy_host'];
$port = $this->config['proxy_port'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt($ch, CURLOPT_PROXY,"http://" . $host . ':' .
$port);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_URL, $uri->__toString());
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
// Save request method for later
$this->method = $method;
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
// Add Proxy-Authorization header
if ($this->config['proxy_user'] && ! isset($headers['proxy-
authorization'])) {
$headers['proxy-authorization'] =
Zend_Http_Client::encodeAuthHeader(
$this->config['proxy_user'], $this-
>config['proxy_pass'], $this->config['proxy_auth']
);
}
$curlHeaders = array();
// Add all headers to the curl header array
foreach ($headers as $k => $v) {
if (is_string($k)) $v = ucfirst($k) . ": $v";
$curlHeaders[] = $v;
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $curlHeaders);
if ($body != null) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
}
$this->result = curl_exec($ch);
// HACK- The server returns chunked transfer encoding at
times, and it's indicated in the header
// However, curl and ZF both attempt to decode, leading to
exceptions being thrown
// There has to be a way to avoid the following line (o
something like it), but haven't figured it out yet
$this->result = str_ireplace('Transfer-encoding:', 'Transfer-
encoding-old:', $this->result);
return $this->result;
}
public function read()
{
return $this->result;
}
/**
* Preform handshaking with HTTPS proxy using CONNECT method
*
* @param string $host
* @param integer $port
* @param string $http_ver
* @param array $headers
*/
protected function connectHandshake($host, $port = 443, $http_ver
= '1.1', array &$headers = array())
{
$request = "CONNECT $host:$port HTTP/$http_ver\r\n" .
"Host: " . $this->config['proxy_host'] . "\r\n";
// Add the user-agent header
if (isset($this->config['useragent'])) {
$request .= "User-agent: " . $this->config['useragent'] . "\r
\n";
}
// If the proxy-authorization header is set, send it to proxy but
remove
// it from headers sent to target host
if (isset($headers['proxy-authorization'])) {
$request .= "Proxy-authorization: " . $headers['proxy-
authorization'] . "\r\n";
unset($headers['proxy-authorization']);
}
$request .= "\r\n";
// Send the request
if (! @fwrite($this->socket, $request)) {
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception("Error
writing request to proxy server");
}
// Read response headers only
$response = '';
$gotStatus = false;
while ($line = @fgets($this->socket)) {
$gotStatus = $gotStatus || (strpos($line, 'HTTP') !==
false);
if ($gotStatus) {
$response .= $line;
if (!chop($line)) break;
}
}
// Check that the response from the proxy is 200
if (Zend_Http_Response::extractCode($response) != 200) {
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception("Unable to
connect to HTTPS proxy. Server response: " . $response);
}
// If all is good, switch socket to secure mode. We have to
fall back
// through the different modes
$modes = array(
STREAM_CRYPTO_METHOD_TLS_CLIENT,
STREAM_CRYPTO_METHOD_SSLv3_CLIENT,
STREAM_CRYPTO_METHOD_SSLv23_CLIENT,
STREAM_CRYPTO_METHOD_SSLv2_CLIENT
);
$success = false;
foreach($modes as $mode) {
$success = stream_socket_enable_crypto($this->socket,
true, $mode);
if ($success) break;
}
if (! $success) {
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception("Unable to
connect to" .
" HTTPS server through proxy: could not negotiate secure
connection.");
}
}
/**
* Close the connection to the server
*
*/
public function close()
{
parent::close();
$this->negotiated = false;
}
/**
* Destructor: make sure the socket is disconnected
*
*/
public function __destruct()
{
if ($this->socket) $this->close();
}
}
I did try the Perl script and faced the same error as you from
GoDaddy. It looks like it needs the same workaround i.e. proxy server
for SSL.
GoDaddy doesn't seem to have any information in their Help Center for
Perl+SSL as they do for PHP.
I will investigate on this further.
-Anirudh
On Jul 1, 2:33 pm, techlover <[EMAIL PROTECTED]> wrote:
> Hello Anirudth,
>
> Thank you for you suggestions. I setup Wireshark and tried it using
> the following code straight from the GApps help pages (no special mods
> made):http://code.google.com/apis/apps/google_apps_provisioning_api_v1.0_re....
>
> I would appreciate your repeating this simple experiment. From what
> I have read in this forum and experienced on my own, GoDaddy and
> Google servers are not playing together well.
>
> The perl script shown was uploaded and run on two different GoDaddy
> hosted accounts of mine (both happen to be registered with GApps). I
> tried all 3 of my GPapps Education accounts where APIs were activated
> via the GApps Control Panel. I was very careful to use the correct
> parameters including Email (of an admin) and his password. In each
> case no output ever occurred. The GoDaddy error logs showed a timeout
> (at the $lwp_object->post call). "https://www.google.com/accounts/
> ClientLogin error: 500 Connect failed: connect: Connection timed out;
> Connection timed out at /home/content/a/b/c/abcadmin/html/cgi/
> auth_token.pl line 25."
>
> BTW, last week I formally submitted this issue as a trouble ticket
> using the Education credentials for one of my Education accounts. I
> received a message that it was being forwarded to the appropriate team
> (Re: [#300182554] Google APIs are not working on GoDaddy). Is this
> Google's formal response to that ticket?
>
> #! /usr/bin/perl -w
>
> use strict;
> use LWP::UserAgent;
>
> # Create an LWP object to make the HTTP POST request
> my $lwp_object = LWP::UserAgent->new;
>
> # Define the URL to submit the request to
> my $url = 'https://www.google.com/accounts/ClientLogin';
>
> # Submit the request with values for the accountType,
> # Email and Passwd variables.
> my $response = $lwp_object->post( $url,
> [ 'accountType' => 'HOSTED',
> 'Email' => '[EMAIL PROTECTED]',
> 'Passwd' => 'admin_password'
> ]
> );
>
> die "$url error: ", $response->status_line unless $response-
>
> >is_success;
>
> # Extract the authentication token from the response
> my $auth_token;
> foreach my $line (split/\n/, $response->content) {
> if ($line =~ m/^SID=(.+)$/) {
> $auth_token = $1;
> last;
> }
>
> }
>
> print "authentication token is $auth_token\n";
>
> Larry (Lawrence H. Ph.D.; Power Poster GApps)
>
> On Jun 30, 9:19 am, "Anirudh (Google)" <[EMAIL PROTECTED]> wrote:
>
> > Hi Larry,
>
> > 'BadAuthentication' is an error response from Google when either the
> > request is malformed or the credentials aren't valid. The request
> > could be malformed due to lack of encoding of special characters or an
> > ill-formatted POST body. Since you are using Zend library with the
> > additional ProxyWithCurl adapter, I would suggest you to check your
> > HTTP Request by using a HTTP sniffer to make sure its well-formatted
> > given that the credentials are valid.
>
> > Here is a link to our FAQ on the same
> > issue:http://code.google.com/support/bin/answer.py?answer=64263&topic=10362
>
> > You can also find information on HTTP tools
> > here:http://code.google.com/support/bin/answer.py?answer=55856&topic=10362
>
> > -Anirudh
>
> > On Jun 28, 1:26 pm, techlover <[EMAIL PROTECTED]> wrote:
>
> > > Hi Julian,
>
> > > Here's what I'm trying to do and the current problem. I want to use
> > > the provisional apis and tried one of them. I made most of the
> > > changes you recommended. Here's part od the code where I deviated but
> > > got an error "BadAuthentication". See anything I did wrong? The error
> > > occurs in getHttpClient.
>
> > > require_once "ProxyWithCurl.php";
> > > require_once "Loader.php";
> > > Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
> > > Zend_Loader::loadClass('Zend_Gdata_Gapps');
>
> > > $email = "[EMAIL PROTECTED]";
> > > $password = "private";
> > > $domain = "mydomain.com";
>
> > > $service = Zend_Gdata_Gapps::AUTH_SERVICE_NAME;
>
> > > $config = array(
> > > 'adapter' =>
> > > 'Zend_Http_Client_Adapter_ProxyWithCurl',
> > > 'proxy_host' => 'proxy.shr.secureserver.net',
> > > 'proxy_port' => 3128
> > > );
> > > // Instantiate a client object
> > > $clientp = new Zend_Http_Client();
> > > $clientp->setConfig($config);
>
> > > $client = Zend_Gdata_ClientLogin::getHttpClient($email, $password,
> > > $service,$clientp);
> > > $service = new Zend_Gdata_Gapps($client, $domain);
>
> > > $service->retrieveAllUsers();
>
> > > Thanks,
>
> > > Larry
>
> > > On Jun 27, 4:28 am, "Julian (Google)" <[EMAIL PROTECTED]> wrote:
>
> > > > Hi Larry,
>
> > > > The Gdata PHP library is developed by the Zend Framework.
>
> > > > You can file a feature request in their Issue Tracker and share your
> > > > thoughts with the communityhttp://framework.zend.com/community/resources
>
> > > > Cheers,
> > > > Julian.
>
> > > > On Jun 26, 3:31 am,techlover<[EMAIL PROTECTED]> wrote:
>
> > > > > Thanks Julian. Slowly I'm beginning to see the issue. While I
> > > > > consider myself to be very computer literate and even a geek, this is
> > > > > not an area for which I am competent. My comment to one of the Google
> > > > > folks fell on deaf ears when I mentioned that Google's APIs should be
> > > > > made to work with one of their two partners -GoDaddy.
>
> > > > > Larry
>
> > > > > On Jun 25, 3:15 am, "Julian (Google)" <[EMAIL PROTECTED]> wrote:
>
> > > > > > Hi Larry,
>
> > > > > > You don't need to purchase a SSL certificate, the library will use
> > > > > > the
> > > > > > one at Google's server for the connection.
>
> > > > > > The timeout is the common issue withGoDaddy, they require HTTPS
> > > > > > through proxy servers that handle connections via tunneling. The
> > > > > > Zend
> > > > > > Library supports a proxy, but it does not support the connection via
> > > > > > tunneling.
>
> > > > > > I haven't used Ryan's workaround, but at the moment I think that is
> > > > > > the only way to use the library withGoDaddy, another option is to
> > > > > > use
> > > > > > Curl and make the requests directly without the Zend Library.
>
> > > > > >GoDaddyhas an article about using Curl with their
> > > > > >proxy:http://help.godaddy.com/article/289
>
> > > > > > Cheers,
> > > > > > Julian
>
> > > > > > On Jun 25, 6:02 am,techlover<[EMAIL PROTECTED]> wrote:
>
> > > > > > > Julian,
>
> > > > > > > I ran into the following error. Does it mean I need to purchase
> > > > > > > an
> > > > > > > SSL certificate? I still haven't gotten things to work using your
> > > > > > > suggestions and those of Ryan but this error made me wonder if I'm
> > > > > > > missing a key element.
> > > > > > > Uncaught exception 'Zend_Gdata_App_HttpException' with message
> > > > > > > 'Unable
> > > > > > > to Connect to ssl://www.google.com:443. Error #110: Connection
> > > > > > > timed
> > > > > > > out'
>
> > > > > > > Thanks,
>
> > > > > > > Larry
>
> > > > > > > On Jun 16, 9:12 am, "Julian (Google)" <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > Hi Larry,
>
> > > > > > > > You can do the include_path and add the Zend classes like this:
>
> > > > > > > > $path = 'ZendGdata-1.5.2/library';
> > > > > > > > set_include_path(get_include_path() . PATH_SEPARATOR . $path);
>
> > > > > > > > require_once 'Zend/Loader.php';
> > > > > > > > Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
> > > > > > > > Zend_Loader::loadClass('Zend_Gdata_Gapps');
>
> > > > > > > > But I found thatGoDaddyneeds proxy settings to connect
> > > > > > > > usingSSL, I
> > > > > > > > recommend you to try what Ryan Boyd posted here:
>
> > > > > > > >http://groups.google.org.in/group/google-calendar-help-dataapi/msg/6e...
>
> > > > > > > > This is for Calendar, but you could adapt it to Google Apps
> > > > > > > > with few
> > > > > > > > changes.
>
> > > > > > > > Julian.
>
> > > > > > > > On Jun 16, 1:43 pm, "Julian (Google)" <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > > Hi Larry,
>
> > > > > > > > > Your include path should be like this:
>
> > > > > > > > > include_path=.../ZendGdata-1.5.2/library/
>
> > > > > > > > > With {...} according to your installation, remember to check
> > > > > > > > > the file
> > > > > > > > > access permissions.
>
> > > > > > > > > Something important aboutGoDaddyis that
> > > > > > > > > someconfigurationchanges
> > > > > > > > > like the php.ini do not take effect immediately,
> > > > > > > > > you may need to wait few hours or run a command line httpd
> > > > > > > > > restart if
> > > > > > > > > you have that access.
>
> > > > > > > > > Julian
>
> > > > > > > > > On Jun 15, 3:12 am,techlover<[EMAIL PROTECTED]> wrote:
>
> > > > > > > > > > BTW, I'm starting with the Provisional APIs. Larry
>
> > > > > > > > > > On Jun 14, 7:46 pm,techlover<[EMAIL PROTECTED]> wrote:
>
> > > > > > > > > > > I'm attempting to set up the php libraries for GApps
> > > > > > > > > > > APIs. I've
> > > > > > > > > > > obtained the files from Zend and put them onto my website
> > > > > > > > > > > hosted by
> > > > > > > > > > >GoDaddy. The php.ini file is visible but adding a line of
> > > > > > > > > > > include_path=absolute_path_mywebsite_root may not be
> > > > > > > > > > > doing anything.
> > > > > > > > > > > Could someone give me an example of setting this?
>
> > > > > > > > > > > When I attempted to run AllTests.php, I received a
> > > > > > > > > > > warning:
> > > > > > > > > > > require_once(PHPUnit/Framework.php)
> > > > > > > > > > > [function.require-once]: failed to
> > > > > > > > > > > open stream... I assume this is related to not having the
> > > > > > > > > > > include_path set correctly.
>
> > > > > > > > > > > I found a website article which seems to indicate that
> > > > > > > > > > > changes are
> > > > > > > > > > > needed in some of the files: HowTo: Use the Zend
> > > > > > > > > > > Framework GData
> > > > > > > > > > > Google Data API onGoDaddyservers located
> > > > > > > > > > > athttp://www.ehartwell.com/InfoDabble/HowTo:_Use_the_Zend_Framework_GDa...
> > > > > > > > > > > Is this really necessary?
>
> > > > > > > > > > > I've attempted to follow the the FAQ guide for how-to set
> > > > > > > > > > > things up
> > > > > > > > > > > but you can see where I'm at. Any answers or pointing me
> > > > > > > > > > > to a good
> > > > > > > > > > >configurationguide (forGoDaddy) would be greatly
> > > > > > > > > > >appreciated.
>
> > > > > > > > > > > Larry
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Apps APIs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-apps-apis?hl=en
-~----------~----~----~----~------~----~------~--~---