Skip to content

Instantly share code, notes, and snippets.

@tessguefen
Forked from steveosoule/accept-json-post-data.xml
Last active December 7, 2016 21:23
Show Gist options
  • Save tessguefen/20954ae244501f82d907cbff31c54e1f to your computer and use it in GitHub Desktop.
Save tessguefen/20954ae244501f82d907cbff31c54e1f to your computer and use it in GitHub Desktop.
Miva s.content_data to Read Raw POST Data
<h2>s.content_data</h2>
<pre><mvt:eval expr="s.content_data"/></pre>
<h2>miva_json_decode(s.content_data, l.settings:json)</h2>
<mvt:assign name="l.result" value="miva_json_decode(s.content_data, l.settings:json)" />
<p><b>&amp;mvt:json:foobar; =</b> &mvt:json:foobar;</p>
<p><b>&amp;mvt:json:message; =</b> &mvt:json:message;</p>
<?php
$data_string = '{"campaign":{"created_at":"2016-03-22 20:05:45.074247-07:00","id":333477,"name":"Widget Title","published":true,"referral_incentive":{"type":"reward_amount","value":5.0}},"created_at":"2016-04-04 23:21:04.145113-07:00","detail_uri":"https://api.friendbuy.com/v1/conversions/43879","fraud":{"fuzzy_email":true,"same_customer":false,"same_email":false,"same_shopper":true},"id":43879,"possible_self_referral":true,"purchase":{"date":"2016-04-04 23:21:04.145113","email":"ssoule@miva.com","ip_address":"127.0.0.1","new_customer":"yes","order_id":"567162","products":[],"total":1337.0},"referrer":{"customer":{"account_id":"friendbuy-sharer","detail_uri":"https://api.friendbuy.com/v1/customers/19486","email":"sharer@example.com","first_name":null,"id":19486,"last_name":null},"email":"sharer@example.com","facebook_friends_count":0,"name":"","twitter_followers_count":0},"reward":null,"rewards":[{"amount":5.0,"created_at":"2016-04-04 23:21:04.897591-07:00","evaluate_at":null,"id":13470,"rejected_reasons":{"same_shopper":"same cookie detected"},"status":"valid","type":"fixed_cash"}],"share":{"campaign":{"created_at":"2016-03-22 20:05:45.074247-07:00","id":333477,"name":"Widget Title","published":true,"referral_incentive":{"type":"reward_amount","value":5.0}},"created_at":"2016-03-30 23:49:35.006194-07:00","detail_uri":"https://api.friendbuy.com/v1/shares/130493","referral_code":"aA","id":130493,"ip_address":"127.0.0.1","message":{"content":"testing","network":"email"},"email_recipients":["friend@example.com"],"sharer":{"customer":{"account_id":"friendbuy-sharer","detail_uri":"https://api.friendbuy.com/v1/customers/19486","email":"sharer@example.com","first_name":null,"id":19486,"last_name":null},"email":"sharer@example.com","facebook_friends_count":0,"name":"","twitter_followers_count":0}},"status":"unmarked"}';
$ch = curl_init('https://www.myurl.com/mm5/merchant.mvc?Screen=friendbuyapi');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
curl_close($ch);
echo $result;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment