I'm planning to save a returned object to a file, for downloading later on to review. For clarity sake, I'm working with an outside API service, and gathering their data, for parsing into another database.
Here's what I have:
<?php
require('class.php');
$client = new connect2Them();
$logged_in = $client->login();
if(!$logged_in){
echo "Not connected!"; die();
}
$records = $client->get_records();
if(count($records < 1){
echo "No records found"; die();
}
$singlerecord = $records[0];
print_r($singlerecord);
?>
The print_r() works fine, and I get back a very very large amount of data. I'm doing all this via command-line, so I want to save it to a text file.
I've added this below my $singlerecord:
<?php
$myFile = "reviewLater.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $singlerecord;
fwrite($fh, $stringData);
fclose($fh);
?>
I get this error from PHP: PHP Warning: fwrite() expects parameter 2 to be string, object given in....
How do I put the print_r() into the reviewLater.txt?