I am trying to upload a text file of data to a soap server with a function called BulkLoadContacts. The request requires a value called
base64Binary
I am creating a file, then querying my database, writing to the file, then connecting to their soap server, then sending my request.
Here is a snippit of my code:
$file = 'tempfile.txt';
$handle = fopen($file, 'w') or die ('Cannot open file: ' . $file);
$list = dbExec("select * from listrak_upload");
foreach ($list as $l){
$data = $l['email'] . "|" . $l['First_Name'] . "|" . $l['Last_Name'];
fwrite($handle, $data);
}
$ap_param = array(
'ListID' => (integer) 252403,
'WSImportDirectives' => array(
'ImportTypeEnum' => 'AddSubscribers',
'ImportProfileTypeEnum' => 'Overwrite',
'FileName' => '',
'HasColumnNames' => true,
'FileName' => $file,
'FileDelimiter' => '|',
),
'fileMappings' => array(
'WSFileMappings' => array(
'FileColumn' => 0,
'IsEmailAddressColumn' => true,
'AttributeID' => 'email',
),
),
'ImportFileStream' => $handle
);
try {
$return = $soapClient->__soapCall("BulkLoadContacts",array('parameter' => $ap_param));
var_dump($return);
}
catch(SoapFault $fault){
var_dump($fault);
}
Here is a code example from the documentation:
Byte[] fileBytes = System.IO.File.ReadAllBytes("C:\\Temp\\ImportFiles\\TestImportFileWithProfile.txt");
Any ideas how to do this in PHP?
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)