- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2019
10:34 PM
08-21-2019
10:34 PM
So if I need to encode this in Magento curl
http://<my system address>:85/?script=WebsiteSQL&tablename=ITEMMASTER&format=json&keyfield=ITEMCODE&condition=ITEMCODE=’313-6F7’&apikey=<key>
I would use the following? but how do I send it Options?
$adminUrl = '<my system address>';$ch = curl_init();
$data = array("script" => "WebsiteSQL" , '"tablename" => "ITEMMASTER" , "format" => "json" , "keyfield" => "ITEMCODE" , "condition" => "ITEMCODE='313-6f7'" , "apikey" => "<key>");
$data_string = json_encode($data);
$ch = curl_init($adminUrl);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_PORT, 85);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded');
$response = curl_exec($ch);
curl_close($sh);
$response= json_decode($response);
Solved! Go to Solution.
Labels:
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2019
11:15 PM
08-21-2019
11:15 PM
Hello @kevin_marshall2
I think you want to use POST and not GET here so it should be like this:
$adminUrl = 'http://<my system address>:85/'; $ch = curl_init(); $data = array("script" => "WebsiteSQL" , '"tablename" => "ITEMMASTER" , "format" => "json" , "keyfield" => "ITEMCODE" , "condition" => "ITEMCODE='313-6f7'" , "apikey" => "<key>"); $data_string = json_encode($data); $ch = curl_init($adminUrl); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_PORT, 85); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'); $response = curl_exec($ch); curl_close($sh); $response= json_decode($response);
If this helps you then please give us kudos and select as solution.
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2019
11:15 PM
08-21-2019
11:15 PM
Hello @kevin_marshall2
I think you want to use POST and not GET here so it should be like this:
$adminUrl = 'http://<my system address>:85/'; $ch = curl_init(); $data = array("script" => "WebsiteSQL" , '"tablename" => "ITEMMASTER" , "format" => "json" , "keyfield" => "ITEMCODE" , "condition" => "ITEMCODE='313-6f7'" , "apikey" => "<key>"); $data_string = json_encode($data); $ch = curl_init($adminUrl); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_PORT, 85); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'); $response = curl_exec($ch); curl_close($sh); $response= json_decode($response);
If this helps you then please give us kudos and select as solution.