I use CartoDB import api to upload csv file correctly, and I can see the 'pointtest' table is created in the cartoDB website. By following command line:
#curl -v -F file=@/mnt/hgfs/D/cartodb/pointtest.csv "https://{username}.cartodb.com/api/v1/imports/?api_key={apikey}"
but when I use php to rewrite this above command line, there are nothing happened,
upload.php
<?php
echo "Hello World";
$url = "https://{username}.cartodb.com/api/v1/imports/?api_key={apikey}";
$file = getcwd()."/pointtest.csv";//locate in /var/www/html/pointtest.csv
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => array(
CURLOPT_SSL_VERIFYPEER => false,
userfile => '@'.$file
)
));
$result = curl_exec($ch);
curl_close($ch);
echo $result;?>
I get a success message
{"item_queue_id":"fcbfd6ag-c8df-47b2-8a16-fa8392576f2c","success":true}
But there is nothing happened on my cartodb web page.
Than I try to use this "item_queue_id" append to my $url and curl_exec(),
there is nothing happened. So I try to test four case as following:
A as I use command line to get the item_queue_id.
B as I use php code to get the item_queue_id.
C as I use command line to upload my "testpoint.csv" data.
D as I use php code to upload my "testpoint.csv" data.
First, A than C, it works well.
Second, A than D, it works well.
Third, B than C, it gets error message as following:
* Connection #0 to host {username}.cartodb.com left intact{"id":"XXX-xXXX-XXXX-XXXX-XXXXXXXXXXXX","user_id":"XXXXXXXX","table_id":null,"data_type":"datasource","table_name":null,"state":"failure","error_code":99999,"queue_id":"aa175163-ec18-4f8a-99eb-d5683264ac0a","tables_created_count":null,"synchronization_id":null,"type_guessing":true,"quoted_fields_guessing":true,"content_guessing":false,"create_visualization":false,"visualization_id":null,"user_defined_limits":"{\"twitter_credits_limit\":0}","get_error_text":{"title":"Unknown","what_about":"Sorry, something went wrong and we're not sure what. Try\n uploading your file again, or <a href='mailto:support@cartodb.com?subject=Unknown error'>contact us</a> and we'll try to help you quickly.","source":"cartodb"},"display_name":"XXX","success":false,"original_url":"","warnings":null}
Fourth, B than D, it shows nothing on my chrome.
I don't know how to deal with it.