phpSPO icon indicating copy to clipboard operation
phpSPO copied to clipboard

Failed to connect to login.microsoftonline.com port 443: Connection refused

Open breugela opened this issue 8 years ago • 2 comments

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";
}

breugela avatar Sep 08 '17 09:09 breugela

I have a very similar issue to this

syl666 avatar Sep 20 '18 07:09 syl666

Hello,

Up, same problem here. In dev server it's ok, same error in production

ornythorink avatar Apr 27 '20 13:04 ornythorink