Failed to connect to login.microsoftonline.com port 443: Connection refused
Hi,
I receive the following message trying to connect to a sharepoint page. below the error and the code. can someone help? thanks,
Error:
Fatal error: Uncaught exception 'Exception' with message 'Failed to connect to login.microsoftonline.com port 443: Connection refused' in C:\xampp\websites\reqwebtool\vendor\vgrem\php-spo\src\Runtime\Utilities\Requests.php:34 Stack trace: #0 C:\xampp\websites\reqwebtool\vendor\vgrem\php-spo\src\Runtime\Utilities\Requests.php(67): Office365\PHP\Client\Runtime\Utilities\Requests::execute(Object(Office365\PHP\Client\Runtime\Utilities\RequestOptions)) #1 C:\xampp\websites\reqwebtool\vendor\vgrem\php-spo\src\Runtime\Auth\SamlTokenProvider.php(92): Office365\PHP\Client\Runtime\Utilities\Requests::post('https://login.m...', NULL, '\xEF\xBB\xBF<s:Envelope ...') #2 C:\xampp\websites\reqwebtool\vendor\vgrem\php-spo\src\Runtime\Auth\SamlTokenProvider.php(60): Office365\PHP\Client\Runtime\Auth\SamlTokenProvider->acquireSecurityToken('<<username>>', '<<password>>') #3 C:\xampp\websites\reqwebtool\vendor\vgrem\php-spo\src\Runtime\Auth\AuthenticationContext.php(69): Office365\PHP\Client\Runtime\Auth\SamlTokenProvider->acquireToken( in C:\xampp\websites\reqwebtool\vendor\vgrem\php-spo\src\Runtime\Utilities\Requests.php on line 34
My Code:
require_once(__DIR__ . '/vendor/autoload.php');
use Office365\PHP\Client\Runtime\Auth\AuthenticationContext;
use Office365\PHP\Client\SharePoint\ClientContext;
use Office365\PHP\Client\SharePoint\ListCreationInformation;
use Office365\PHP\Client\SharePoint\SPList;
$authCtx = new AuthenticationContext($Url);
$authCtx->acquireTokenForUser($UserName,$Password);
$ctx = new ClientContext($Url,$authCtx); //initialize REST client
$web = $ctx->getWeb();
$list = $web->getLists()->getByTitle($listTitle); //init List resource
$items = $list->getItems(); //prepare a query to retrieve from the
$ctx->load($items); //save a query to retrieve list items from the server
$ctx->executeQuery(); //submit query to SharePoint Online REST service
foreach( $items->getData() as $item ) {
print "Task: '{$item->Title}'\r\n";
}
I have a very similar issue to this
Hello,
Up, same problem here. In dev server it's ok, same error in production