Post by JAY6390 » Mon Jul 27, 2015 10:11 pm

It would probably make more sense to have a separate api directory in the system over the library directory as there will be a lot of api classes

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by pm-netti » Mon Jul 27, 2015 11:58 pm

JAY6390 wrote:It would probably make more sense to have a separate api directory in the system over the library directory as there will be a lot of api classes
Yes, those new classes can also create to directory system/library/api/, thought is make resition curl connect.

User avatar
Active Member

Posts

Joined
Sat Apr 07, 2012 11:22 pm
Location - Kittilä, Finland

Post by Daniel » Mon Sep 07, 2015 10:40 pm

the next release is nearly ready. it has all the fixes in. going to do a testing release first.

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by sunsys » Tue Sep 08, 2015 12:57 am

Daniel wrote:the next release is nearly ready. it has all the fixes in. going to do a testing release first.
Thank a million Daniel, god bless your soul, can we know the approx release date please.

Thank You.

Regards,
Sun Systems
Industrial Electronics and Instrumentation


User avatar
Active Member

Posts

Joined
Tue Jan 27, 2015 5:19 am

Post by straightlight » Fri Sep 11, 2015 7:53 am

I chatted with a hosting team today regarding the 406 error message of loopbacks over cURL. According to their statement, it's because the user agent is not being used upon every call from Opencart within the API. cURL should be instantiated at all times by including the user agent.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by retti » Fri Sep 11, 2015 10:38 pm

I don't see the point why should curl be used within the same application, same server, etc...

Does somebody knows the way to be able to debug code in curl request? I am using zend debugger, but after entering curl, the debugger session is lost.

The admin product edit contains lots of bugs, which I would like to fix otherwise our staff has to work manually in Excel(!!!) every product edit.

Newbie

Posts

Joined
Fri Sep 11, 2015 9:03 pm

Post by straightlight » Sat Sep 12, 2015 12:58 am

You could use the curl_error function to track error events.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by waitz » Wed Sep 16, 2015 5:28 pm

I have followed the exact steps, and it is not working....:

Re. 2. & 3. Uploaded the contents of the "upload_contents_to_secondary_domain" to my secondary domain and loaded the url in a browser, and it gives me the message: Curlbounce Script Found at: http://myotherdomain.no/curlbounce.php

Re. 4. Using that url, edited the "upload_contents_to_opencart_store/vqmod/xml/api_curl_bounce.xml" file and placed the url http://myotherdomain.no/curlbounce.php in the 3 spots.

Re. 5. Upload the vqmod/xml file to our store's vqmod/xml folder

Re. 6. Tried to add an order history in the Admin->Sales->Orders->View area on the "History" tab.

Result: No success. The page just stalls and the 'Add History' Button stays with the message 'Loading'

Checked system/logs/api_curlbounce_debug.txt: [http_code] => 200

Checked curlbounce.txt file on my secondary site to see what it is receiving. Looks OK.
Tried also to uncomment "file_put_contents" lines. This created curlbounce_post.txt which also looks OK.
Tested again and still not working.

WHAT CAN I DO???

Opencart: 3.0.2.1 | Inside Mijoshop 4.0.8 in Joomla 3.9.5


New member

Posts

Joined
Tue Jan 10, 2012 12:22 am

Post by Qphoria » Thu Sep 17, 2015 11:07 pm

waitz wrote:I have followed the exact steps, and it is not working....:

Re. 2. & 3. Uploaded the contents of the "upload_contents_to_secondary_domain" to my secondary domain and loaded the url in a browser, and it gives me the message: Curlbounce Script Found at: http://myotherdomain.no/curlbounce.php

Re. 4. Using that url, edited the "upload_contents_to_opencart_store/vqmod/xml/api_curl_bounce.xml" file and placed the url http://myotherdomain.no/curlbounce.php in the 3 spots.

Re. 5. Upload the vqmod/xml file to our store's vqmod/xml folder

Re. 6. Tried to add an order history in the Admin->Sales->Orders->View area on the "History" tab.

Result: No success. The page just stalls and the 'Add History' Button stays with the message 'Loading'

Checked system/logs/api_curlbounce_debug.txt: [http_code] => 200

Checked curlbounce.txt file on my secondary site to see what it is receiving. Looks OK.
Tried also to uncomment "file_put_contents" lines. This created curlbounce_post.txt which also looks OK.
Tested again and still not working.

WHAT CAN I DO???
Hmm, if you are getting 200 then that should be good then. Perhaps you don't have an API user setup and enabled in the system settings?

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by quangwilliam212 » Wed Oct 07, 2015 3:22 pm

what happen with I use Https ?


Posts

Joined
Thu May 21, 2015 2:24 pm


Post by waitz » Wed Oct 07, 2015 4:47 pm

quangwilliam212 wrote:what happen with I use Https ?
What do you mean?

Opencart: 3.0.2.1 | Inside Mijoshop 4.0.8 in Joomla 3.9.5


New member

Posts

Joined
Tue Jan 10, 2012 12:22 am

Post by Qphoria » Thu Oct 08, 2015 12:53 am

quangwilliam212 wrote:what happen with I use Https ?
Just change the url in the xml file to use https:// if you want.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by quangwilliam212 » Thu Oct 08, 2015 9:59 am

Qphoria wrote:
quangwilliam212 wrote:what happen with I use Https ?
Just change the url in the xml file to use https:// if you want.
Yes, It mean. Thanks you so much for answer, Qphoria. I will try it and feedback :).


Posts

Joined
Thu May 21, 2015 2:24 pm


Post by Qphoria » Thu Oct 08, 2015 9:39 pm

retti wrote:I don't see the point why should curl be used within the same application, same server, etc...

Does somebody knows the way to be able to debug code in curl request? I am using zend debugger, but after entering curl, the debugger session is lost.

The admin product edit contains lots of bugs, which I would like to fix otherwise our staff has to work manually in Excel(!!!) every product edit.
It was an easy way to call to the catalog side from the admin side. It looked better on paper and was an unforeseen side effect that many hosts don't allow it. It was completely removed in 2.1.x

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by pablormago » Wed Apr 04, 2018 11:56 pm

Qphoria wrote:
Tue Jun 23, 2015 10:50 pm
In OpenCart 2.0, there is a new API system that uses a "curl" call (curl is a server-side web call) from the admin area to the front end. This method of calling the same domain from the admin side to the catalog side results in a "loopback" connection. It seems a good number of people have an issue with OpenCart 2.0's new API system due to their servers disallowing curl loopbacks to the same domain.

We've tried many ways to work around this
- Subdomain - Trying to use a subdomain like "api.mysite.com" and change the curl url calls to use that subdomain, But that didn't work. The server still detected the loopback
- localhost/127.0.0.1 - Tried uses the localhost, but most shared servers don't allow this anyway and give a 404 error

So the only working method I've found was to have a completely separate secondary domain and have the curl call pass through that domain, and redirect back to your store, then have the response go back to that site and redirect back to your store. Effectively creating a hop and bypassing the loopback check.

I've attached the files here.

Requirements:
- vQmod installed on your opencart 2.0 store
- A secondary domain (not subdomain). Can even be on the same host, just a different url.

1. Extract the zip
2. Upload the contents of the "upload_contents_to_secondary_domain" to somewhere in your secondary domain.
3. Try to load that file in a browser. You should see something like

Code: Select all

"Curlbounce Script found at http://somesite.com/curlbounce.php"
4. Using that url, EDIT the "upload_contents_to_opencart_store/vqmod/xml/api_curl_bounce.xml" file and globally replace

Code: Select all

http://example.com/curlbounce.php
with the url you used to load that page on your secondary site. There should be 3 spots.
5. Now upload that vqmod/xml file to your store's vqmod/xml folder
6. Now try to add an order history in the Admin->Sales->Orders->View area on the "History" tab. If you get a success then it worked :)

If it fails, check the system/logs/api_curlbounce_debug.txt on your opencart site to see what the http_code value is returning. If it isn't 200 then it isn't working correctly. Also check the curlbounce.txt file on your secondary site to see what it is receiving. You may need to edit that file to uncomment the // from the "file_put_contents" lines in the code.

I do a lot of upgrades and this script has worked on the last 3 clients I upgraded so it should hopefully help others.

I believe Daniel has changed the way the API works in versions later than 2.0.3.1 so you likely won't need this script in the future, whenever that happens.
Is it possible to adapt the code to 2.3.0.2? I have two different domains, but api functions seems to be different....

Thanks im advance

Newbie

Posts

Joined
Wed Feb 21, 2018 9:50 pm

Post by straightlight » Wed Apr 04, 2018 11:58 pm

The cURL function for local APIs were removed on more recent OC versions since web hosters were blocking these methodologies on being applied for local purposes.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by pablormago » Thu Apr 05, 2018 12:06 am

straightlight wrote:
Wed Apr 04, 2018 11:58 pm
The cURL function for local APIs were removed on more recent OC versions since web hosters were blocking these methodologies on being applied for local purposes.
So why i have the syntaxerror unexpected end of file json... When i click on Next when editing an order??

I have an Ssl certificate, https set up on both config files, created and selected a new Api user... The only thing im waiting is my hosting provider to turn off mod_security.

Im a little frustated...

Newbie

Posts

Joined
Wed Feb 21, 2018 9:50 pm

Post by straightlight » Thu Apr 05, 2018 12:18 am

At this point, if you are still using an OC version that uses cURL locally between controller files, I would strongly suggest to upgrade your OC version to at least v2.3.0.2 release.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by pablormago » Thu Apr 05, 2018 12:19 am

straightlight wrote:
Thu Apr 05, 2018 12:18 am
At this point, if you are still using an OC version that uses cURL locally between controller files, I would strongly suggest to upgrade your OC version to at least v2.3.0.2 release.
Im on 2.3.0.2 and still getting this error. Can i pm you?

Newbie

Posts

Joined
Wed Feb 21, 2018 9:50 pm

Post by straightlight » Thu Apr 05, 2018 12:21 am

Then, the issue is not with the topic you are posting into. Send me a PM to troubleshoot this issue knowing whether it's an extension issue or an issue originating from the core.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 16 guests