An OAuth2 client provider for Office 365 to be used with thephpleague/oauth2-client
Update custom_components/smartthinq_sensors/translations/da.json
Fix spelling error
Co-authored-by: Ramy Aboul Naga ramy.naga@gmail.com
Thank you for a great integration.
I've added a Danish translation.
Create Danish translation
@greew both links php manual sais abaout use filesystem for load namespaced functions.
You keep on saying that the PHP documentation says something about loading - it does not!
Number of times the word load or autoload is mentioned in the following links:
The <?php use ?> statement does not load the class file. You have to do this with the <?php require ?> statement or by using an autoload function.
(https://www.php.net/manual/en/language.namespaces.importing.php#114265).You also keep on saying that the PHP documentation mentions using filesystem for loading namespace functions - it also does not.
https://www.php.net/manual/en/language.namespaces.basics.php:
The filesystem text you keep mentioning does not say anything about that you can load the namespaced stuff. Actually this is the same for for the filesystem itself, that you keep mentioning. By entering the filename in a simple text editor or a command line, the file will not be loaded. You will have to use a program to open the file.
This is the same in PHP - you have to load the namespaced stuff into the file first. This usually happens with include
or one of it's friends require
, include_once
, require_once
.
But instead of having to manually load all files that you have to use, the PHP core have added a function called spl_autoload_register()
. As the documentation on that page says, it's about autoloading classes - NOT functions.
@PrinsFrank as you can be random but I think an open source project should have no owner. Latest committers could be part of the project.
That might be how you think it should be, but since the majority of the GitHub community does not see it this way, you're taking a bad approach by just referencing a bunch of random people.
No one has read the php manual and seen that there, in text, not in code, talks about how the namespaced functions should be loaded, with the file system.
I hope you will go through this and my previous comments and actually try and read AND understand, what is being written.
@IgorDePaula You clearly chose to ignore what @zanbaldwin said before:
Things the documentation does say you can do with namespaced functions: load, import, resolve. Things the documentation doesn't say you can do with namespaced functions: autoload.
Of the two links you provided to the PHP core, neither of them tells us anything about autoloading. They only show us how to deal with namespaced classes, function and constants when they have already been loaded, either by already being in the same file as the calling code, by being loaded by require
/import
or by using spl_autoload_register
.
If you take a look at https://www.php.net/manual/en/language.oop5.autoload.php you will see that this is very precisely called "Autoloading Classes". There is no mention of autoloading functions or consts. Actually, the comment https://www.php.net/manual/en/language.oop5.autoload.php#124770 tells us as the first thing, that autoloading functions is not supported in PHP.
You now ask us to provide a PoC or technical article about how this is NOT possible?
You also say, you have showed us something concrete. Good - I have not taken those same two documentation articles and shown you even another one, that what you say can be accomplished, is not supported in PHP.
@IgorDePaula
You've been told multiple times now, that PHP doesn't support autoloading of namespaced functions. You've been told multiple times that Composer doesn't support autoloading of namespaced functions because PHP doesn't support it.
You keep on saying, that you think Composer has a bug, because you think the PHP documentation says otherwise.
THEN: If you actually believe, that PHP does support autoloading of namespaced functions, please show us an example of how you would achieve this without using Composer. If you actually are able to do this, then we might get into a discussion about it, but until then I'm outta here!
@dudestefani
Sorry - my bad. I had forgot the context.
Let's try the same in the get_oauth_token.php file:
Replace
$token = $provider->getAccessToken(
'authorization_code',
[
'code' => $_GET['code']
]
);
with
try {
$token = $provider->getAccessToken(
'authorization_code',
[
'code' => $_GET['code']
]
);
} catch (IdentityProviderException $e) {
print "<pre>";
echo "An error occured" . PHP_EOL;
echo "Exception message: {$e->getMessage()}" . PHP_EOL;
echo "Response: {$e->getResponseBody()}";
die;
}
and check the exception message for more info :)
@dudestefani @matteo-cavalli
In the last few lines of azure_xoauth2.php
, try changing from
//send the message, check for errors
if (!$mail->send()) {
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message sent!';
}
to
try {
$status = $mail->send();
} catch (IdentityProviderException $e) {
print $e->getMessage();
var_dump($e);
exit(1);
}
//send the message, check for errors
if (!$status) {
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message sent!';
}
And let us know the output of the exception.
Hopefully the exception message can tell us a bit more about, what went wrong :)
@matteo-cavalli Have you tried the wiki article??