Skip to content

Instantly share code, notes, and snippets.

Created October 13, 2017 08: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 anonymous/bd8ab3f2a17342a64a0205b53740de1a to your computer and use it in GitHub Desktop.
Save anonymous/bd8ab3f2a17342a64a0205b53740de1a to your computer and use it in GitHub Desktop.
can I use the same page (function.php) to insert my xml call?
<?php
$xml = "<customer><activation-code>".rand(100000,999999)."</activation-code>
<area-code-id type=\"integer\"></area-code-id>
<billing-failure-date type=\"datetime\" nil=\"true\"/>
<created-at type=\"datetime\"></created-at>
<email>".$current_user->user_email."</email>
<first-name>".$valueVorname."</first-name>
<id type=\"integer\"></id>
<language-id type=\"integer\">2</language-id>
<last-name>".$valueNachname."</last-name>
<npvr-limit type=\"integer\" nil=\"true\"/>
<npvr-quota type=\"integer\">360000</npvr-quota>
<other-than-stb-devices-limit type=\"integer\">1</other-than-stb-devices-limit>
<phone></phone>
<pin>".rand(1000,9999)."</pin>
<pvr-limit>NO_LIMIT</pvr-limit>
<secondary-pin>".rand(1000,9999)."</secondary-pin>
<status>enabled</status>
<stb-devices-limit type=\"integer\">1</stb-devices-limit>
<updated-at type=\"datetime\"></updated-at>
<uuid></uuid>
<external-id nil=\"true\"/>
<npvr-quota-used type=\"integer\">1</npvr-quota-used>
<npvr-limit-used type=\"integer\">1</npvr-limit-used>
<area-code-external-id nil=\"true\"/>
<language-external-id nil=\"true\"/>
<address-attributes>
<city>".$valueOrt."</city>
<street>".$valueStrasse."</street>
<postal-code>".$valuePost."</postal-code>
<province-id>119</province-id>
</address-attributes>
</customer>";
$url = 'https://xxx.xxx.xx.33:xxxx/rest/customers';
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml','Authorization: Basic QTFDVjVsaGl5d1d2NXh3UWJ0OFE6'));
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $xml );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt( $ch, CURLOPT_TIMEOUT, 10);
$data = curl_exec($ch);
//print $data;
//var_dump($data);
$xml = simplexml_load_string($data);
$json = json_encode($xml);
$arr = json_decode($json,true);
//print_r($arr['id']);
if(curl_errno($ch))
print curl_error($ch);
else
curl_close($ch);
$resultVorname = wpuef_get_field('c11');
$valueVorname=$resultVorname->value;
echo $valueVorname, "<br>";
$resultNachname = wpuef_get_field('c15');
$valuenachname=$resultNachname->value;
echo $valueNachname, "<br>";
$resultStrasse = wpuef_get_field('c23');
$valueStrasse=$resultStrasse->value;
echo $valueStrasse, "<br>";
$resultPostleitzahl = wpuef_get_field('c31');
$valuePost=$resultPostleitzahl->value;
echo $valuePost, "<br>";
$resultOrt = wpuef_get_field('c35');
$valueOrt=$resultOrt->value;
echo $valueOrt, "<br>";
$resultTelefon = wpuef_get_field('c43');
$valueTelefon=$resultTelefon->value;
echo $valueTelefon, "<br>";
$resultSprache = wpuef_get_field('c12');
$value1=$resultSprache->value;
echo $value1, "<br>";
echo 'User email: ' . $current_user->user_email . '<br />';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment