in Education by
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)

1 Answer

0 votes
by
Maybe something like this: $fileName = "test.txt"; $rawFile = fread(fopen($fileName, "r"), filesize($fileName)); $B64File = base64_encode($rawFile) In the param array: 'ImportFileStream' => $B64File Maybe PHP client SOAP engine encodes to B64 automatically. If this is the case, comment $B64File = base64_encode($rawFile) and send $rawFile instead.

Related questions

0 votes
    When I run the server using php bin/console server:run I get the following error. There are no ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    I think I have an error in my code here - $('#form input[type=radio]').val();. JS: $( ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I think I have an error in my code here - $('#form input[type=radio]').val();. JS: $( ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I think I have an error in my code here - $('#form input[type=radio]').val();. JS: $( ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I think I have an error in my code here - $('#form input[type=radio]').val();. JS: $( ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I currently have the following code: My problem is that the image when submitted isn't doing the same ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 28, 2022 in Education by JackTerrance
0 votes
    I currently have the following code: My problem is that the image when submitted isn't doing the same ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 28, 2022 in Education by JackTerrance
0 votes
    I am aware that I can use array_unique(array_merge($a,$b)); to merge two arrays and then remove ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 14, 2022 in Education by JackTerrance
0 votes
    Recently I asked a question regarding preg_match_all with php, and i got the perfect solution as expected ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 11, 2022 in Education by JackTerrance
0 votes
    I'm trying to insert data to the database and at the same time uploading an image to the path. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    I want to load Google fonts in the head-section of my page using a php-function. My -area looks like this: ... ... Now ... I do this, there will be a "1" displayed (because of the...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    I want to load Google fonts in the head-section of my page using a php-function. My -area looks like this: ... ... Now ... I do this, there will be a "1" displayed (because of the...
asked May 30, 2022 in Education by JackTerrance
0 votes
    I want to load Google fonts in the head-section of my page using a php-function. My -area looks like this: ... ... Now ... I do this, there will be a "1" displayed (because of the...
asked May 26, 2022 in Education by JackTerrance
0 votes
    I've following two path path1- test/hello/hello.php path2- test/hello1/hello1.php //notice the one ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 19, 2022 in Education by JackTerrance
0 votes
    In Laravel, there is a function return back();, which returns the user to the previous page. Is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 19, 2022 in Education by JackTerrance
...