Page 1 of 1

[solved] PHP Notice:Undefined index: key in api/login.php

Posted: Fri Jun 10, 2016 5:19 pm
by veritas75
Hi Guys,

I am getting the following error.

PHP Notice: Undefined index: key in xxx/catalog/controller/api/login.php on line 11

I am using OC 2.2.0.0

I noticed this error when i logged in and went to update an order and started getting Undefined Error when logging into the order page.

Travis

Re: PHP Notice:Undefined index: key in ..../api/login.php li

Posted: Fri Jun 10, 2016 6:02 pm
by i2Paq
Admin of Storefront?

Re: PHP Notice:Undefined index: key in ..../api/login.php li

Posted: Fri Jun 10, 2016 9:03 pm
by veritas75
What do you mean the admin of the storefront??

Re: PHP Notice:Undefined index: key in ..../api/login.php li

Posted: Fri Jun 10, 2016 9:21 pm
by straightlight
Are you trying to authenticate on an order from an installed extension? It seems like the authentication process fails from a specific admin page.

Admin page: Back-end interface of Opencart for administrative purposes.
Store-front end: For customers to visit your shop.

Re: PHP Notice:Undefined index: key in ..../api/login.php li

Posted: Sat Jun 11, 2016 11:52 am
by veritas75
I am not sure how that would effect what is happening.

All I am doing is going into orders, going to view an order and getting a pop up that states undefined error.

I check the error log and that is what I see??

Re: PHP Notice:Undefined index: key in ..../api/login.php li

Posted: Sat Jun 11, 2016 8:00 pm
by straightlight
veritas75 wrote:I am not sure how that would effect what is happening.

All I am doing is going into orders, going to view an order and getting a pop up that states undefined error.

I check the error log and that is what I see??
It would definitely affect if the defined key has not been properly defined from the installed contribution. Even though you might simply do it from the order page, it does not prevent the installed contribution to authenticate to the API. More information would be needed on that end regarding installed contributions you might be using for the orders or if you do not use any contributions for the orders.

Re: PHP Notice:Undefined index: key in ..../api/login.php li

Posted: Fri Aug 05, 2016 10:22 pm
by jhebb
Looks like if you have set the site up on full SSL then there is an issue in the /admin/controller/sale/order.php. If you look in the console I was seeing this error.

jquery-2.1.1.min.js:4 XMLHttpRequest cannot load httpss://www.site.com/index.php?route=api/login. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

If you notice there is an extra 's' in the https request.

In the order php file, you will find this line.

Code: Select all

$data['store_url'] = $this->request->server['HTTPS'] ? str_replace("http", "https", $order_info['store_url']) : $order_info['store_url'];
Look like the string replace is taking the http out and replacing it with https. Problem is that is already https in the line, so it's taking out http from the https and making it httpss. I just made the line this.

Code: Select all

$data['store_url'] = $this->request->server['HTTPS'] ? str_replace("https", "https", $order_info['store_url']) : $order_info['store_url'];
Now it's taking out the https and replacing it with https and the URL is correct and the error when looking at orders is gone.

Re: [solved] PHP Notice:Undefined index: key in api/login.ph

Posted: Thu Sep 15, 2016 1:07 pm
by mobilewill
Thanks for this information to get this fixed. This happened to me with my force SSL for the entire site. I added this fix to my SSL VQMod which I have published if anyone needs it.

VQMod Enable SSL with fix