javascript - Bulk REST API POST Processing -


I am migrating 40,000 records from one system to another, and the only way to import data into the received system is to be API Post Call

I'm looking for advice on the fastest approach to repetition through 40,000 Easy API calls. I have data formatted as JSON, and I assign objects to 40+ In JSON files are selected using PHP. Ideally, I would probably like to handle POST asynchronous, PHP, Javascript, node. Any advice on how to use JS or Bash would be very helpful.

You can post calls with PHP with multiple functions of curl. Comments in code.

  $ Json_files = array ('1.json', '2.json', ..., '40 .json '); $ count = 0; foreign currency ($ json_files $ json_file) {$ list_of_objects = json_decode (file_get_contents ( $ Json_file), true (; $ List_of_objects) {// log error is continuing;} // size 10 part of the arrays / or whatever # you run $ chunked_list = array_chunk ($ list_of_objects, 10) together Want; foreign currency ($ chunked_list $ as Chuck) {$ handles = array (); $ Mh = curl_multi_init (); Forex (as part of the $ item $) {$ ch = curl_init ( 'on your API URL'); Curl_setopt ($ CH, CURLOPT_RETURNTRANSFER, 1); Curl_setopt ($ CH, CURLOPT_POST, 1); Curl_setopt ($ ch , CURLOPT_POSTFIELDS, http_build_query ($ item)); Curl_multi_add_handle ($ mh, $ ch); // indexes handles your item ID, // you know that $ $ [[id ']] = $ ch;} // Perform all 10 positions simultaneously / Continue when all are running full $ = zero; {$ Status = curl_multi_exec (running $ mh, $); } While ($ position === CURLM_CALL_MULTI_PERFORM || $ running); Forex handles ($ $ item_id = & gt; $) {if (curl_multi_getcontent ($ handles) == 'my success message') {// log $ item_id success file} else {// log $ item_id You can try again later to fail the file) curl_multi_remove_handle ($ mh, $ handle); } Curl_multi_close ($ mh); $ Counts + = 10; Print "$ counts ... \ n"; }}    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -