save_json_to_mongo($js, $objname, $jsoninv_collection); } else { echo "_"; $apikey = get_api_key(); $js = $js2; } } $ftype = $js->data->properties->funding_type; if (!isset($js->data->properties->money_raised_usd)) { echo "no usdsum, skip\n"; continue; } $usdsum = $js->data->properties->money_raised_usd; $fcurr = $js->data->properties->money_raised_currency_code; if (isset($fround->data->properties->series)) { $fser = $js->data->properties->series; } else { $fser = null; } $round_date = strtotime($js->data->properties->announced_on); $fdatetrust = $js->data->properties->announced_on_trust_code; if (!isset($js->data->relationships->funded_organization)) { //print_r($js);sleep(10); echo "no rcpt, skip\n"; continue; } $rcpt_path = strip_first_part($js->data->relationships->funded_organization->items[0]->path); $rcpt_name = strip_characters($js->data->relationships->funded_organization->items[0]->path); $investments_collection->insert(array("id" => $doc['id'], "rcptname" => $rcpt_name, "recipient" => $rcpt_path, "funding_type" => $ftype, "usd_sum" => $usdsum, "curr" => $fcurr, "ser" => $fser, "fdate" => $round_date, "datetrust" => $fdatetrust)); echo "."; }
continue; // skip this element } save_json_to_mongo($js, $objid, $jsondata_collection); if (!isset($js->data->properties->role_investor)) { continue; } if (!isset($js->data->relationships->investments)) { continue; } //if (true!=$js->data->properties->role_investor) continue; if ("Person" == $doc['type']) { $objname = strip_characters($js->data->properties->last_name . " " . $js->data->properties->first_name); } if ("Organization" == $doc['type']) { $objname = strip_characters($js->data->properties->name); } echo "[" . $current_item . "/" . $items_count . "] : {$objname}\n"; $fund = array(); $fund_num = 0; foreach ($js->data->relationships->investments->items as $funding) { $round_uuid = strip_first_part($funding->funding_round->path); $fund[$fund_num] = $round_uuid; $fund_num++; if (!isset($investments[$round_uuid])) { // add new investment $newround = array(); $newround['id'] = $round_uuid; //$round_fname="/tmp/cb/$round_uuid.json"; //$newround['recipient']=strip_characters($funding->invested_in->name); $rcpt_path = strip_first_part($funding->invested_in->path);