以下是客户的json文件: https://we4cs.myshopify.com/admin/customers.json
我有一个应该提交的html表单并更新json文件。我该怎么做?请指教。
以下是customers.json
的json文件{"customers":[{"accepts_marketing":false,"orders_count":0,"addresses":[{"company":"test","city":"test","address1":"test","name":"test
test","zip":"56576","address2":"test","country_code":"AZ","country":"Azerbaijan","province_code":null,"phone":"54765765878","last_name":"test","province":"hgjghj","first_name":"test"}],"tags":"","id":51036842,"last_name":"test","note":null,"email":"test@test.com","first_name":"test","total_spent":"0.00"},{"accepts_marketing":false,"orders_count":0,"addresses":[{"company":"","city":"newark","address1":"23
smith","name":"gggggggggggggggg
hhhhhhhhhhhhhhhhhh","zip":"08786","address2":"","country_code":"US","country":"United
States","province_code":"NJ","phone":"","last_name":"hhhhhhhhhhhhhhhhhh","province":"New
Jersey","first_name":"gggggggggggggggg"}],"tags":"","id":49755872,"last_name":"hhhhhhhhhhhhhhhhhh","note":null,"email":"gregadkins2001@aol.com","first_name":"gggggggggggggggg","total_spent":"0.00"},{"accepts_marketing":false,"orders_count":0,"addresses":[{"company":"dsfsdf","city":"newark","address1":"12
dfsdf","name":"sdfsdf
sdfsdf","zip":"08876","address2":"","country_code":"US","country":"United
States","province_code":"NJ","phone":"","last_name":"sdfsdf","province":"New
Jersey","first_name":"sdfsdf"}],"tags":"","id":47565872,"last_name":"sdfsdf","note":null,"email":"sdfdfsdaf@aol.com","first_name":"sdfsdf","total_spent":"0.00"},{"accepts_marketing":true,"orders_count":0,"addresses":[{"company":"xcvxcvcx","city":"bridgewater","address1":"112
asdasd","name":"zxcxzcxz
cxvxcvxv","zip":"08875","address2":"asdasd","country_code":"US","country":"United
States","province_code":null,"phone":"323123123","last_name":"cxvxcvxv","province":"","first_name":"zxcxzcxz"},{"company":"xcvxcvcx","city":"bridgewater","address1":"112
asdasd","name":"zxcxzcxz
cxvxcvxv","zip":"08875","address2":"asdasd","country_code":"US","country":"United
States","province_code":"NJ","phone":"323123123","last_name":"cxvxcvxv","province":"New
Jersey","first_name":"zxcxzcxz"}],"tags":"","id":40799732,"last_name":"cxvxcvxv","note":"","email":"handful4me@aol.com","first_name":"zxcxzcxz","total_spent":"0.00"}]}
答案 0 :(得分:0)
也就是说,您可能最好根据需要生成JSON并仅将其用作传输机制。真正的数据库几乎总是存储和操作的更好选择。
答案 1 :(得分:0)
写入文件的基本方式,您需要fopen
,fwrite
,当然还需要fclose
。
<?php
if($_POST['json'])
{
$open_json = fopen('json_file.json', 'w');
if($open_json)
{
if(fwrite($open_json, $_POST['json'] === FALSE)
{
die('failed to write to file');
}
fclose($open_json);
}
else
{
die('failed to open file');
}
}
?>
编辑:既然您已经从API中提到过它,就不能使用它来写入外部服务器。