我有这段代码可以打印从 API xml 中提取的某些结果
<?php
echo "<h1>Approval Stats</h1><br /><br />";
echo "Report for Agent Name: <b>Bhaskar</b><br />";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_URL,'http://login.leadkitchen.com/affiliates/api/4/reports.asmx/CampaignSummary' );
$post_array = array(
'api_key' => 'abc',
'affiliate_id' => 'abc',
'start_date' => '10/8/2012',
'end_date' => '10/11/2012',
'sub_affiliate' => 'email',
'start_at_row' => '1',
'row_limit' => '0',
'sort_field' => 'offer_name',
'sort_descending' => 'true'
);
//url-ify the data
foreach($post_array as $key=>$value)
{
$post_array_string .= $key.'='.$value.'&';
}
$post_array_string = rtrim($post_array_string,'&');
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_POST,count($post_array ));
curl_setopt($ch,CURLOPT_POSTFIELDS,$post_array_string);
$response = curl_exec($ch);
// print_r($response);
$xml = new SimpleXMLElement($response);
echo "<pre>";
echo "Process Name: "; echo $xml->campaigns->campaign->vertical_name, PHP_EOL;
echo "Approvals: "; echo $xml->campaigns->campaign->conversions, PHP_EOL;
echo "Applied: "; echo $xml->campaigns->campaign->clicks, PHP_EOL;
?>
此链接中可能的 xml 响应http://z4site.com/social/pay/summary.php
<campaigns>
<campaign>
<vertical_name>Free Stuff</vertical_name>
<clicks>6</clicks>
<conversions>1</conversions>
</campaign>
</campaigns>
但我需要创建一个表单,让用户在使用 ajax 生成结果之前手动输入这些字段。
- sub_affiliate
- 开始日期
- 结束日期
从这个段落
$post_array = array(
'api_key' => 'abc',
'affiliate_id' => 'abc',
'start_date' => '10/8/2012',
'end_date' => '10/11/2012',
'sub_affiliate' => 'email',
'start_at_row' => '1',
'row_limit' => '0',
'sort_field' => 'offer_name',
'sort_descending' => 'true'
);
我该怎么做..我应该为此创建一个 HTML 文件吗?你能建议我的代码吗?谢谢
html 文件http://z4site.com/social/pay/report.html
<html>
<head>
</head>
<body>
<form method="post" action="summary.php">
<input type="text" name="sub_affiliate" />
<input type="text" name="start_date" />
<input type="text" name="end_date" />
<input type="submit" name="submit" value="Search" />
</form>
</body>
</html>