私のアプリでは、php-script を使用して少量のデータを cartodb-table に送信したいと考えています。SQL-APIを使用したいと思います。私のアプリは、次のような形式でデータを解析します。
https://{account}.cartodb.com/api/v2/sql?q=INSERT INTO test_table (column_name, column_name_2, the_geom) VALUES ('this is a string', 11, ST_SetSRID(ST_Point(-110, 43),4326))&api_key={Your API key}
いくつかの機能を試しましhttp_get, file_get_contents, http_request
たが、データがアカウントに渡されません。URLをコピー&ペーストしてブラウザで開くと、すべてが追加されます。
正しい機能は何ですか?非常に多くの異なるものがあります... PHP-HTTP-Functions
編集
このソリューションのコードを使用すると、応答を出力すると、次のエラーが発生します。
{"error":["syntax error at end of input"]}
ブラウザ内でこれを取得します:
{"rows":[],"time":0.038,"fields":{},"total_rows":1}
今の私のリクエストコード:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullurl);
// Set so curl_exec returns the result instead of outputting it.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Get the response and close the channel.
$response = curl_exec($ch);
curl_close($ch);
print($response);