OneNoteDev / OneNoteAPISamplePHP

Code sample with examples of how to use the OneNote API on PHP.
Apache License 2.0
36 stars 7 forks source link

PHP error in callback.php #5

Open swbuehler opened 9 years ago

swbuehler commented 9 years ago

When trying to use the PDF posting button, the post fails, and the PHP log shows the following:

[02-Dec-2014 12:52:54 America/New_York] PHP Notice:  Undefined index: code in C:\inetpub\wwwroot\OneNote\callback.php on line 140
[02-Dec-2014 12:52:54 America/New_York] PHP Notice:  Undefined index: error in C:\inetpub\wwwroot\OneNote\callback.php on line 176
[02-Dec-2014 12:52:54 America/New_York] PHP Notice:  Undefined index: error_description in C:\inetpub\wwwroot\OneNote\callback.php on line 177

I logged out from Live and back in, and tried the post again, this time getting the following PHP error:

[02-Dec-2014 12:56:40 America/New_York] PHP Notice:  Use of undefined constant SERVER_NAME - assumed 'SERVER_NAME' in C:\inetpub\wwwroot\OneNote\callback.php on line 222

I'm using PHP 5.6.0 on an IIS 8.5 install.

gakselrod commented 9 years ago

Hi swbuehler-

For the first set of log lines, this implies that something went wrong when trying to auth with the auth server. Are you able to reproduce this error? Can you tell us the full URL you're redirected to (callback.php?...) ? Sometimes there's useful information in the query string. The easiest way to see what's going on is by watching the requests with Fiddler.

Some easy things to double check: make sure you've set all the config variables per the instructions under the Set up the sample in the readme -- for both callback.php and index.php.

Also note that you must have cURL installed for this code sample to work.

For the second notice you posted -- this notice can be safely ignored -- it's not an error, only a warning. To make it go away, change line 222 from:

setrawcookie(AUTHCOOKIE, buildQueryString($cookieValues), 0, '/', $_SERVER[SERVER_NAME]);

to (notice the quotes around SERVER_NAME)

setrawcookie(AUTHCOOKIE, buildQueryString($cookieValues), 0, '/', $_SERVER["SERVER_NAME"]);
swbuehler commented 9 years ago

I got authentication to work, and got this back:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"

      xmlns:msgr="http://messenger.live.com/2009/ui-tags">

<head>

    <title>Live SDK Callback Page</title>

    <script src="//js.live.net/v5.0/wl.js" type="text/javascript"></script>

</head>

<body>

</body>

</html>

When I did one of the submit buttons, I got back:


<html><head><title>OneNote Service API Result</title></head><body><h1>OneNote Service API Result</h1><h2>Something went wrong...</h2></b></h2><h3>Response</h3><pre></pre><br /><a href="index.php">&lt;- Go back</a></body></html>

Nothing.

Looks like sign-in worked, but submitting the page gave me back nothing.

From: CompMan86 [mailto:notifications@github.com] Sent: Wednesday, December 3, 2014 7:16 PM To: OneNoteDev/OneNoteAPISamplePHP Cc: Steven Buehler Subject: Re: [OneNoteAPISamplePHP] PHP error in callback.php (#5)

Hi swbuehler-

For the first set of log lines, this implies that something went wrong when trying to auth with the auth server. Are you able to reproduce this error? Can you tell us the full URL you're redirected to (callback.php?...) ? Sometimes there's useful information in the query string. The easiest way to see what's going on is by watching the requests with Fiddler.

Some easy things to double check: make sure you've set all the config variables per the instructions under the Set up the sample https://github.com/OneNoteDev/OneNoteAPISamplePHP#set-up-the-sample in the readme -- for both callback.php and index.php.

Also note that you must have cURL installed for this code sample to work.

For the second notice you posted -- this notice can be safely ignored -- it's not an error, only a warning. To make it go away, change line 222 from:

setrawcookie(AUTHCOOKIE, buildQueryString($cookieValues), 0, '/', $_SERVER[SERVER_NAME]);

to (notice the quotes around SERVER_NAME)

setrawcookie(AUTHCOOKIE, buildQueryString($cookieValues), 0, '/', $_SERVER["SERVER_NAME"]);

— Reply to this email directly or view it on GitHub https://github.com/OneNoteDev/OneNoteAPISamplePHP/issues/5#issuecomment-65516761 . https://github.com/notifications/beacon/AATQqKqyevADXDxFLQ_CEl3UG5CibieHks5nT58ugaJpZM4DDHJo.gif

machandw-microsoft commented 9 years ago

Hi Steven,

Can you check the title of the page where you see “Something went wrong”.

I suspect the authentication request did not succeed, based on what you are seeing.

If so, the title of the page will contain more details. A common reason is that the redirect URL in the application’s registration page does not match the URL to reach the callback module on the server on which your application is hosted.

Thanks, Manoj

From: Steven Buehler [mailto:notifications@github.com] Sent: Thursday, December 4, 2014 4:59 PM To: OneNoteDev/OneNoteAPISamplePHP Subject: Re: [OneNoteAPISamplePHP] PHP error in callback.php (#5)

I got authentication to work, and got this back:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"

xmlns:msgr="http://messenger.live.com/2009/ui-tags">

<head>

<title>Live SDK Callback Page</title>

<script src="//js.live.net/v5.0/wl.js" type="text/javascript"></script>

</head>

<body>

</body>

</html>

When I did one of the submit buttons, I got back:


<html><head><title>OneNote Service API Result</title></head><body><h1>OneNote Service API Result</h1><h2>Something went wrong...</h2></b></h2><h3>Response</h3><pre></pre><br /><a href="index.php">&lt;- Go back</a></body></html>

Nothing.

Looks like sign-in worked, but submitting the page gave me back nothing.

From: CompMan86 [mailto:notifications@github.com] Sent: Wednesday, December 3, 2014 7:16 PM To: OneNoteDev/OneNoteAPISamplePHP Cc: Steven Buehler Subject: Re: [OneNoteAPISamplePHP] PHP error in callback.php (#5)

Hi swbuehler-

For the first set of log lines, this implies that something went wrong when trying to auth with the auth server. Are you able to reproduce this error? Can you tell us the full URL you're redirected to (callback.php?...) ? Sometimes there's useful information in the query string. The easiest way to see what's going on is by watching the requests with Fiddler.

Some easy things to double check: make sure you've set all the config variables per the instructions under the Set up the sample https://github.com/OneNoteDev/OneNoteAPISamplePHP#set-up-the-sample in the readme -- for both callback.php and index.php.

Also note that you must have cURL installed for this code sample to work.

For the second notice you posted -- this notice can be safely ignored -- it's not an error, only a warning. To make it go away, change line 222 from:

setrawcookie(AUTHCOOKIE, buildQueryString($cookieValues), 0, '/', $_SERVER[SERVER_NAME]);

to (notice the quotes around SERVER_NAME)

setrawcookie(AUTHCOOKIE, buildQueryString($cookieValues), 0, '/', $_SERVER["SERVER_NAME"]);

— Reply to this email directly or view it on GitHub https://github.com/OneNoteDev/OneNoteAPISamplePHP/issues/5#issuecomment-65516761 . https://github.com/notifications/beacon/AATQqKqyevADXDxFLQ_CEl3UG5CibieHks5nT58ugaJpZM4DDHJo.gif

— Reply to this email directly or view it on GitHubhttps://github.com/OneNoteDev/OneNoteAPISamplePHP/issues/5#issuecomment-65731845.