Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Yahoo search marking API examples with php-4.3.11

Posted on 2006-03-22
3
Medium Priority
?
333 Views
Last Modified: 2014-11-12
I am looking for some good examples using ysm API that are compatible with php4. I found one sample script but it uses DOM which won’t work with anything less than PHP5 and I am not ready to upgrade yet so I need to find another example that will work with my version of PHP.

sample.php

<?php

$USERNAME   = $_SERVER[''];
$PASSWORD   = $_SERVER[''];
$KEY        = $_SERVER[''];
$ACCOUNT_ID = $_SERVER[''];

$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>
0
Comment
Question by:mit1290
  • 2
3 Comments
 
LVL 4

Expert Comment

by:Gee_Orge
ID: 16262253
Hi,

Well is your server has the domxml extenssion enabled?

if there is you can use DOMXML instead of DOM.

0
 
LVL 4

Accepted Solution

by:
Gee_Orge earned 2000 total points
ID: 16262481
if you have it an exmple is something like this

<?php

$USERNAME   = $_SERVER[''];
$PASSWORD   = $_SERVER[''];
$KEY        = $_SERVER[''];
$ACCOUNT_ID = $_SERVER[''];

$host = "x-secure-test.overture.com";
$url = "https://$host/index.jhtml?_DARGS=/index.jhtml";

//$dom = new DOMDocument('1.0', 'utf-8');
$dom = domxml_new_doc('1.0');

// DTCRequest tag
//$temp = $dom->CreateElement('DTCRequest');
$temp = $dom->new_child('DTCRequest');
print_r($temp);
//$temp->setAttribute('username', $USERNAME);
$temp->set_attribute('username', $USERNAME);
//$temp->setAttribute('password', $PASSWORD);
$temp->set_attribute('password', $PASSWORD);
//$temp->setAttribute('key',      $KEY);
$temp->set_attribute('key', $KEY);
//$temp->setAttribute('xmlns',    'urn:/ows/aws/1.2');
$temp->set_attribute('xmlns', 'urn:/ows/aws/1.2');
//$temp->setAttribute('xmlns:xs', 'http://www.w3.org/2001/XMLSchema-instance');
$temp->set_attribute('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");
$temp->set_attribute('xs:schemaLocation', "urn:/ows/aws/1.2 https://$host/schema/dtc/1.2/dtc_request.xsd");
$req_root = $dom->append_child($temp);


# Actions tag
$temp = $dom->create_element('Actions');
$temp->set_attribute('accountId', $ACCOUNT_ID);
$action_root = $req_root->append_child($temp);

// *the* action
$temp = $dom->create_element('GetAccountBalance');
$action_root->append_child($temp);

$the_xml = $dom->dump_mem();
?>

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>
0
 

Author Comment

by:mit1290
ID: 16262672
Worked great. Thanks!
0

Featured Post

Managing Security Policy in a Changing Environment

The enterprise network environment is evolving rapidly as companies extend their physical data centers to embrace cloud computing and software-defined networking. This new reality means that the challenge of managing the security policy is much more dynamic and complex.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the wake of AWS' S3 outage, we want to discuss the importance of storage and data diversification in the event of a hack, crash, or system disruption. We spoke with Experts Exchange’s COO Gene Richardson for a deeper understanding.
The decision to migrate to the cloud is not a simple one—many factors, such a cost, ease of use, and ongoing maintenance come into play. The goal is always for cloud platforms to make storage and backups more seamless and effective. Here’s a look at…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question