Commision Junction是一家关联公司的名称。我不熟悉SOAP,WSDL和Web服务,但希望快速测试从其联盟api返回的数据。虽然不能使它工作。他们为API
提供了一个页面我试过像smtg:
public function testCJApi() {
$url = "http://" . $this->user . ":" . $this->password . "@datatransfer.cj.com/datatransfer/files/" . $this->account . "/outgoing/commission_report.csv";
$xml = simplexml_load_file($url);
if (isset($xml)) {
return ($xml
? $this->formatJsonReturn($xml, array("txt"=>"CJ Results OK","code"=>""))
: $this->formatJsonReturn("", array("txt"=>"CJ Results Empty","code"=>""))
);
}
}
但它没有给我任何结果。我只需要快速测试回来的数据。 他们提供的API链接是 http://api.affiliatewindow.com/v4/MerchantService?wsdl
答案 0 :(得分:0)
我自己弄清楚了:
public function testCJApi() {
$uri = "https://commission-detail.api.cj.com/v3/commissions?date-type=posting&start-date=2013-02-15&end-date=2013-02-17"; // can be other api uri, this is one of them
$context = stream_context_create(
array(
'http' => array(
'method' => 'GET',
'header' => 'Authorization: ' . 'YOUR API KEY GOES HERE'
)
)
);
$x = file_get_contents($uri, false, $context);
$response = new SimpleXMLElement($x);
return $response->asXML();
}