0

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.....

user
  • 217
  • 1
  • 10
  • Not sure why this was closed. It's a completely clear question relating to the InfusionSoft API, with a clear answer. It's not broad, as it's tagged **php**. The answer involves using the InfusionSoft PHP SDK to add a file to the database via the API. Pretty simple... – rnevius Feb 25 '15 at 13:07

1 Answers1

1

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);

?>
rnevius
  • 26,578
  • 10
  • 58
  • 86