示例#1
0
function get_investment_round($full_uuid, $apikey)
{
    global $investments;
    global $jsoninv_collection;
    $inv_uuid = strip_first_part($full_uuid);
    if (!isset($investments[$inv_uuid])) {
        // get this new investment round
        $fround = null;
        $res2 = askhost("http://api.crunchbase.com/v/2/funding-round/" . $inv_uuid . "?user_key={$apikey}", FALSE, "", "", "1", 60000, "", true);
        $fround = json_decode($res2['data']);
        if (isset($fround->data->uuid)) {
            save_json_to_mongo($fround, $inv_uuid, $jsoninv_collection);
            echo "+";
        }
        // valid obj
    } else {
        echo "-";
    }
    return true;
}
            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 ".";
}
示例#3
0
     $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);
         $newround['recipient'] = $rcpt_path;
         $fround = null;
         if (isset($fullinv[$round_uuid])) {
             $mnginv = load_json_from_mongo($round_uuid, $jsoninv_collection);
             $fround = json_decode(bzdecompress($mnginv['jsondata']->bin));
             echo "+";
         }
         if (!isset($fround->data->uuid)) {
             echo "\nbad investment data: " . print_r($fround, true) . "\ntrying to reload ";
             $res2 = askhost("http://api.crunchbase.com/v/2/funding-round/" . $round_uuid . "?user_key={$apikey}", FALSE, "", "", "1", 60000, "", true);
             $fround = json_decode($res2['data']);
             if (isset($fround->data->uuid)) {
                 save_json_to_mongo($fround, $round_uuid, $jsoninv_collection);
                 //file_put_contents($round_fname, json_encode($fround,JSON_PRETTY_PRINT) );
                 echo "-";
     if ("Organization" == $js->data->type) {
         $objname = strip_characters($js->data->properties->name);
     }
     $markets = array();
     if (isset($js->data->relationships->markets)) {
         foreach ($js->data->relationships->markets->items as $market) {
             $markets[] = $market->name;
         }
         // each market
     } else {
         $markets[] = "null";
     }
     $fund = array();
     if (isset($js->data->relationships->investments)) {
         foreach ($js->data->relationships->investments->items as $funding) {
             $round_uuid = strip_first_part($funding->funding_round->path);
             $fund[] = $round_uuid;
         }
     }
     //$markets=json_encode($markets);
     $fulldata_collection->insert(array("id" => $doc['id'], "markets" => $markets, "type" => $js->data->type, "name" => $objname, "investments" => $fund));
     echo ".";
     if ($need_update_inv) {
         update_related($js);
     }
     if ($current_item > $items_count) {
         die("done!\n");
     }
 }
 echo "cursor finished\n";
 $resumerec = $current_item;