Skip to content

Instantly share code, notes, and snippets.

@jay-snee
Last active May 10, 2016 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jay-snee/359f600003d4e4dbff6b05b098b089a8 to your computer and use it in GitHub Desktop.
Save jay-snee/359f600003d4e4dbff6b05b098b089a8 to your computer and use it in GitHub Desktop.
<?php
class UserExporter {
function export_account($user) {
$remote = 'https://my-lovely-endpoint.com';
$data = array(
'user' => array(
'namef' => $user['namef'],
'namel' => $user['namel'],
'address1' => $user['address1'],
'address2' => $user['address2'],
'address3' => $user['address3'],
'county' => $user['county'],
'postcode' => $user['postcode'],
'country' => $user['country'],
'email' => $user['email'],
'telephone' => $user['telephone'],
'max_subscriptions' => $user['max_subscriptions']
)
);
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($remote, false, $context);
var_dump($result);
}
}
// Example
//
// $user_account_data = array(
// 'namef' => "Bob",
// 'namel' => "McBobson",
// 'address1' => "123 Somewhere",
// 'address2' => "Somewhere Street",
// 'address3' => "",
// 'county' => "Tyne and Wear",
// 'postcode' => "NE1 1AB",
// 'country' => "United Kingdom",
// 'email' => "bob@example.com",
// 'telephone' => "+441234567",
// 'max_subscriptions' => "1",
// 'expiryDate' => "01/01/2017"
// );
//
// $user_exporter = new UserExporter;
// $user_exporter->export_account($user_account_data);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment