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"
Code: Select all
http://example.com/curlbounce.php
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.