The task is
1) First to generate the csv file from the database (that i have done)
2) now upload the generated and downloaded csv file to infusionsoft api
<?php
$host="localhost";
$uname="root";
$pass="";
$database = "detail";
$connection=mysql_connect($host,$uname,$pass);
$selectdb=mysql_select_db($database) or die("Database could not be selected");
$output = "";
$table = "information"; // Enter Your Table Name
$sql = mysql_query("select * from $table");
$columns_total = mysql_num_fields($sql);
for ($i = 0; $i < $columns_total; $i++) {
$heading = mysql_field_name($sql, $i);
$output .= '"'.$heading.'",';
}
$output .="\n";
while ($row = mysql_fetch_array($sql)) {
for ($i = 0; $i < $columns_total; $i++) {
$output .='"'.$row["$i"].'",';
}
$output .="\n";
}
$filename = "myFile.csv";
header('Content-type: application/csv');
header('Content-Disposition: attachment; filename='.$filename);
echo $output;
exit;
?>
from this code the csv file is generated and downloaded ... now how to upload the csv file in infusionsoft api.....
You should use the FileService API. Using the PHP SDK, you would use the uploadFile() function. The method would look something like:
<?php
$fileName = 'some_csv_file.csv';
$base64Enc = base64_encode($output);
$app->uploadFile($fileName, $base64Enc);
?>