Does anyone know of any good example ysm api code using php? I found one but I am getting
Call to undefined function: createelement() in /yapi/sample.php on line 14
I have domxml enabled and xmlrpc.
This example was only tested on php5 and I am running 4.3.11 so I dont know if that is the issue or not so I am trying to find some other examples calling yahoo marking api using php.
Here is the example code
<?php
$USERNAME = $_SERVER['YSM_DTCXML_USERNAME'];
$PASSWORD = $_SERVER['YSM_DTCXML_PASSWORD'];
$KEY = $_SERVER['YSM_DTCXML_LICENSEKEY'];
$ACCOUNT_ID = $_SERVER['YSM_DTCXML_ACCOUNTID'];
$host = "x-secure-test.overture.com";
$url = "https://$host/index.jhtml?_DARGS=/index.jhtml";
$dom = new DOMDocument('1.0', 'utf-8');
// DTCRequest tag
$temp = $dom->createElement('DTCRequest');
$temp->setAttribute('username', $USERNAME);
$temp->setAttribute('password', $PASSWORD);
$temp->setAttribute('key', $KEY);
$temp->setAttribute('xmlns', 'urn:/ows/aws/1.2');
$temp->setAttribute('xmlns:xs', 'http://www.w3.org/2001/XMLSchema-instance');
$temp->setAttribute('xs:schemaLocation', "urn:/ows/aws/1.2 https://$host/schema/dtc/1.2/dtc_request.xsd");
$req_root = $dom->appendChild($temp);
# Actions tag
$temp = $dom->createElement('Actions');
$temp->setAttribute('accountId', $ACCOUNT_ID);
$action_root = $req_root->appendChild($temp);
// *the* action
$temp = $dom->createElement('GetAccountBalance');
$action_root->appendChild($temp);
$the_xml = $dom->saveXML();
?>
XML Request:<br />
<textarea cols="80" rows="15">
<?= $the_xml ?>
</textarea>
<br />
<?php
$request = array();
$request['xml'] = urlencode($the_xml);
$request['_D:/go2/xml/XMLRequestHandler.submit='] = '';
$request_str = "";
foreach ($request as $k=>$v) {
$request_str .= "$k=".utf8_encode($v)."&";
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request_str);
$data = curl_exec($ch);
if (curl_errno($ch)) {
print curl_error($ch);
exit;
}
curl_close($ch);
?>
XML Response:<br />
<textarea cols="80" rows="15">
<?= $data ?>
</textarea>