s22_tech Moderator Od United States Člen od okt 2019 s22_tech 15 nov 2023 22:11 How do you call this API from an external PHP script? I'm assuming via cURL? How would you pass in the username and password in a GET scenario?
tim Founder Od Sweden Člen od máj 2013 tim 16 nov 2023 05:10 https://username:password@domain.tld/api.php/orders/ But it sounds like you could make use of a CLI implementation: https://www.litecart.net/en/addons/465/litecart-cli-client
s22_tech Moderator Od United States Člen od okt 2019 s22_tech 3 feb 2024 22:25 I'm still curious if this can be called via cURL, or is the URL format you gave above the only way to call it?
tim Founder Od Sweden Člen od máj 2013 tim 4 feb 2024 01:31 cURL has no limitations of HTTP Basic Auth or GET, POST, PATCH, DELETE requests. See cURL RESTful examples on the web.
s22_tech Moderator Od United States Člen od okt 2019 s22_tech 4 feb 2024 02:50 OK. Apparently the data needs to be passed as JSON. This works: curl -X POST --user 'name:pass' --header 'Content-Type: application/json' --data '{"code":"xx","name":"Xtra","url_type":"none"}' https://domain.com/api.php/languages Is there any way to allow us to pass normal cURL key=value pairs and have the API convert it to JSON, if needed?
s22_tech Moderator Od United States Člen od okt 2019 s22_tech 4 feb 2024 05:37 Nevermind. I worked it out and converted it to use the cURL key=value pairs. Was there a reason you chose JSON for the input here or was it just personal preference? Just curious if I should use it as-is, or go with my converted script.
tim Founder Od Sweden Člen od máj 2013 tim 4 feb 2024 19:48 JSON dominates the industry when it comes to APIs and portable data. I think it's clean flexible and robust. Easier to read and has compatibility with most if not all programming languages. You said PHP so simply do json_encode($data) instead of http_build_query($data).