Last active
July 6, 2022 16:33
-
-
Save steveosoule/51fbe51c085d85efccf8079a7fd1d836 to your computer and use it in GitHub Desktop.
Miva - mvt:call to PHP-middleware to perform HTTP GET with POST Data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<mvt:assign name="l.data_for_api:thing_1" value="'Foobar'" /> | |
<mvt:assign name="l.data_for_api:thing_2" value="'Lorem ipsum...'" /> | |
<mvt:capture variable="l.json_string"> | |
<mvt:do file="g.Module_JSON" name="l.success" value="JSON_Output( l.data_for_api )" /> | |
</mvt:capture> | |
<mvt:call action="'https://ssoule.mivamerchantdev.com/php/mvt-call-converter.php'" method="'GET'" fields="'json_string'"> | |
<mvt:eval expr="s.callvalue" /> | |
</mvt:call> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url = 'https://ssoule.mivamerchantdev.com/php/example-api.php'; | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $_REQUEST['json_string']); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$result = curl_exec($ch); | |
curl_close($ch); | |
echo $result; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$fp = fopen('php://input', 'r'); | |
$data_for_api = stream_get_contents($fp); | |
echo "Request Method: " . $_SERVER['REQUEST_METHOD'] . "\n\n"; | |
echo "l.data_for_api: \n\n $data_for_api"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Request Method: GET | |
l.data_for_api: | |
{ | |
"thing_1": "Foobar", | |
"thing_2": "Lorem ipsum..." | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment