I'm trying to access Gmail by using three-legged Oauth PHP code provided by Google ('google-mail-xoauth-tools') here: http://code.google.com/apis/gmail/oauth/code.html. I have my domain registered and everything seems to go fine with OAuth, but after I authorize access I get this error:
Fatal error: Uncaught exception 'Zend_Mail_Protocol_Exception' with message
'cannot connect to host; error = Connection refused (errno = 111 )'
in /home/tchaymor/public_html/gmail/Zend/Mail/Protocol/Imap.php:100
Stack trace: #0 /home/tchaymor/public_html/gmail/Zend/Mail/Protocol/Imap.php(61):
Zend_Mail_Protocol_Imap->connect('imap.gmail.com', '993', true)
#1 /home/tchaymor/public_html/gmail/three-legged.php(170):
Zend_Mail_Protocol_Imap->__construct('imap.gmail.com', '993', true)
#2 {main} thrown in /home/tchaymor/public_html/gmail/Zend/Mail/Protocol/Imap.php on line 100
This is my first time using OAuth with any Google products, so it could be something totally brainless I'm missing. Any suggestions would be most welcome (as suggestions for easier alternatives). I'm more on the designer rather than coder end, so the simpler the better.
Effectively, this is failing:
fsockopen('ssl://imap.gmail.com', 993);
Several options:
1) The error would suggest google is actively blocking you, perhaps you have tested & failed a bit to much, and just have to wait untill a temporary blockade is lifted.
2) The error would be different, but just to be sure: allow_url_fopen is enabled?
3) Local firewall? (What does a telnet imap.gmail.com 993 from the server give you?)
4) Broken OpenSLL libraries are also possible, try to connect a valid https site: fsockopen("ssl://google.com",443,$errno,$errstr) or die($errstr);
Related
I wanted Google plus login in my PHP website. I tried to integrate it from : http://www.codexworld.com/login-with-google-api-using-php
When I try to login, It throws error:
Fatal error: Uncaught exception 'Google_IOException' with message 'HTTP Error: (0) Failed to connect to accounts.google.com port 443: No route to host' in /home/thewiref/public_html/mastkids.in/test_google/src/io/Google_CurlIO.php:128 Stack trace: #0 /home/thewiref/public_html/mastkids.in/test_google/src/auth/Google_OAuth2.php(101): Google_CurlIO->makeRequest(Object(Google_HttpRequest)) #1 /home/thewiref/public_html/mastkids.in/test_google/src/Google_Client.php(131): Google_OAuth2->authenticate(Array, NULL) #2 /home/thewiref/public_html/mastkids.in/test_google/index.php(8): Google_Client->authenticate() #3 {main} thrown in /home/thewiref/public_html/mastkids.in/test_google/src/io/Google_CurlIO.php on line 128
Same code is working perfect in different domain and server. So what could be issue in this server?
Check your Firewall settings and network connectivity to see if you are able to connect to the network.
Try running the following
<?php
$read = file_get_contents("https://google.com");
echo $read;
If you are able to see the google page(even if it is distorted).
If not then your system has a network connectivity issue or DNS issues.
Can someone tell me, I'm using curl in other ways on this machine, so I know it works, but it's just loaded as a php extension, and the dll is called php_curl.dll
Is curl so much more? I can see it can me downloaded multiple places, and I'm wondering if my problem is that I'm missing some curl installation.
I've read this, but I'm not that familiar with curl
My trouble story
I'm trying to connect to Google Analytics Reporting V4
I've been following this tutorial (Earlier I've used V3 on another server).
I've been informed it had some trouble in the docs right now (whitch I've experienced as well) therefor I've used the google-api-2-client as discussed here.
It got me further, but the newest problem is throwing me of...
I get this Message:
"Fatal error: Uncaught GuzzleHttp\Exception\ConnectException: cURL error 7: Failed to connect to www.googleapis.com port 443: Connection refused (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) in D:\www\rest\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:186 Stack trace: #0 D:\www\rest\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(150): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array) #1 D:\www\rest\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(103): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory)) #2 D:\www\rest\vendor\guzzlehttp\guzzle\src\Handler\CurlHandler.php(43): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory)) #3 D:\www\rest\vendor\guzzlehttp\guzzle\src\Handler\Proxy.php(28): GuzzleHttp\Handler\CurlHandler->__invoke(Object(G in D:\www\rest\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 186"
Maybe the firewall blocks outward connections on port 443 (HTTPS).
I am trying to use Google Analytics API. After I enabled Analytic API I received my client_secrets.p12 and downloaded the API client library. I then replaced the service_account_email and changed the key_file_location. How ever when I run my script 'HelloAnalytics.php', I get an error:
PHP Fatal error: Uncaught exception 'Google_IO_Exception' with
message 'Failed to connect to accounts.google.com port 443: Operation
timed out' in
/Users/weiqi.tan/Downloads/ga_api/google-api-php-client/src/Google/IO/Curl.php:115
Stack trace:
0
/Users/weiqi.tan/Downloads/ga_api/google-api-php-client/src/Google/IO/Abstract.php(136):
Google_IO_Curl->executeRequest(Object(Google_Http_Request)) 1
/Users/weiqi.tan/Downloads/ga_api/google-api-php-client/src/Google/Auth/OAuth2.php(342):
Google_IO_Abstract->makeRequest(Object(Google_Http_Request)) 2
/Users/weiqi.tan/Downloads/ga_api/google-api-php-client/src/Google/Auth/OAuth2.php(314):
Google_Auth_OAuth2->refreshTokenRequest(Array) 3
/Users/weiqi.tan/Downloads/ga_api/HelloAnalytics.php(30):
Google_Auth_OAuth2->refreshTokenWithAssertion(Object(Google_Auth_AssertionCredentials))
4 /Users/weiqi.tan/Downloads/ga_api/HelloAnalytics.php(105):
getService() 5 {main} thrown in
/Users/weiqi.tan/Downloads/ga_api/google-api-php-client/src/Google/IO/Curl.php
on line 115
I don't know if anyone else ever had the same problem. Please tell me why this happened and how to solve it.
I had same problem today so
I just disable the firewall and it worked for me
I am using avg internet security
At first I tried just connecting with PDO in PHP. However, I get access denied messages. I can use the exact same commands to connect to the command line interface, but php gives this error from PDO:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [1045] Access denied for user 'avt_root'#'localhost' (using password: YES)' in C:\inetpub\wwwroot\index.php:3 Stack trace: #0 C:\inetpub\wwwroot\index.php(3): PDO->__construct('mysql:host=loca...', 'avt_root', '[**]') #1 {main} thrown in C:\inetpub\wwwroot\index.php on line 3
$db = new PDO("mysql:host=localhost;dbname=AVT_TIME", "avt_root", "[**]");
So next I tried just connecting with mysql_connect to troubleshoot maybe having the PDO parameters incorrect:
$mysql = mysql_connect("localhost", "avt", "[**]");
However, even this gives me pretty much the same error:
Warning: mysql_connect(): Access denied for user 'avt'#'localhost' (using password: YES) in C:\inetpub\wwwroot\index.php on line 2
Server Configuration:
IIS7.0 with PHP running under fast_cgi and MySQL installed with correct extensions chosen in php.ini file.
Any and all help is appreciated, minus any comments regarding correct username and password, I have checked and triple checked for both the avt_root and avt accounts. The password for both is actually the same, and both can log in via the CLI over remote desktop.
localhost can be a little wonky in mysql-land. The standard mysql interface library, which mysql_*() functions use, internally redefine localhost to be a local unix-domain socket connection. This is purey for efficiency, as unix sockets do not have the overhead that TCP sockets do.
PDO, which is probably using mysqlnd, will not have that problem. localhost will mean 127.0.0.1 and it'll be trying to use a TCP socket.
Make sure that your avt account is set up as avt#127.0.0.1 to allow TCP connections.
I eventually gave up on this and completely reinstalled MySQL and am just going to use the root account, as we have high enough security that I don't have to worry too much about someone messing with an intranet only site.
I just follow same code from Facebook SDK example.
If FB App point to my local desktop, it will get Facebook uid and user basic information (ex email) if APP get permission from OAUTH request.
But when I upload files to server, executing $facebook->api('/me');
Fatal error: Uncaught CurlException: 28: connect() timed out! thrown in
/xxx/src/facebook.php on line 622
I still can't figure out why. It comes from CURL or SSL setting?
My remote server support SSL and CURL is enabled. My local is only CURL but no SSL support.
I think my Facebook SDK is old version, only facebook.php without base_facebook.php.
I try to use new version but can't run any program because crt error.
You get this error because your host cannot access the Facebook API. It might have an old version of Open SSL, can you check the current version on the server?
Try to connect using SSL from your local setup as well as it might be easier to debug on your local machine.
Also, see about that crt (CRC?) error and try to fix that first (don't shave too many Yak's though).