0
排序我有這樣的代碼打印了一定的成績,從API XML拉PHP的形式以XML格式結果從API
<?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
- 起始日期
- END_DATE
從此對
$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'
);
我怎麼辦that..should我創建一個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>
你能解釋一下嗎?我是編碼新手。我得到的錯誤..謝謝 – nikhnd
你將不得不添加到你的問題上面的所有錯誤。給我所有你使用的代碼和你遇到的所有錯誤。告訴我你對什麼感到困惑等等。 – teh1
我用上面的表單做了一個新的html頁面。並在上面的代碼中插入該PHP行..它給錯誤..我應該在哪裏插入你提到的代碼? – nikhnd