Affilinet SOAP WSDL php脚本 - >输出为CSV

时间:2017-05-04 06:07:54

标签: php xml csv soap wsdl

跟进我的另一个问题,我在这里有一个带有SOAP WSDL请求的php脚本,以从Affilinet获取优惠券代码。 php示例有效,输出是数组。

如何从中获取.csv文件?

以下是代码:

<?php

// Set webservice endpoints
define("WSDL_LOGON", "https://api.affili.net/V2.0/Logon.svc?wsdl");
define("WSDL_WS", "https://api.affili.net/V2.0/PublisherInbox.svc? wsdl");

// Set credentials
$username = 'xxxxxx'; // the publisher ID
$password = 'xxxxxxx'; // the publisher web services password

// Send a request to the Logon Service to get an authentication token
$soapLogon = new SoapClient(WSDL_LOGON);
$token = $soapLogon->Logon(array(
'Username'  => $username,
'Password'  => $password,
'WebServiceType' => 'Publisher'
));

// Set DisplaySettings parameters
$displaySettings = array(
'CurrentPage' => 1,
'PageSize' => 1000,
'SortBy' => 'LastChangeDate',
'SortOrder' => 'Descending'
);

// Set SearchVoucherCodesRequestMessage parameters
$params = array(
'StartDate' => strtotime("now"),
'EndDate' => strtotime("now"),
'VoucherCodeContent' => 'Filled',

);

// Send a request to the Publisher Inbox Service
$soapRequest = new SoapClient(WSDL_WS);
$response = $soapRequest->SearchVoucherCodes(array(
'CredentialToken' => $token,
'DisplaySettings' => $displaySettings,
'SearchVoucherCodesRequestMessage' => $params
));

// Show response
//print_r($response);


/*

echo '<pre>';
echo print_r($response);
echo '</pre>';
*/


$file = fopen("gutscheine.csv","w");

foreach ($response as $line)
{
fputcsv($file,explode(',',$line));
}

fclose($file); ?>

最后一点是我尝试创建csv。创建了csv文件,但没有任何内容。

我不擅长php,所以请耐心等待:)。

谢谢, Karolin

0 个答案:

没有答案