本文整理汇总了PHP中api::connect_api方法的典型用法代码示例。如果您正苦于以下问题:PHP api::connect_api方法的具体用法?PHP api::connect_api怎么用?PHP api::connect_api使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api
的用法示例。
在下文中一共展示了api::connect_api方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display_api_results
function display_api_results($test_code)
{
$api = new api();
$curl_result = $api->connect_api($test_code);
$i = 0;
echo "<pre>";
$size = sizeof($curl_result['report']['completed_test']);
for ($i; $i < $size; $i++) {
echo $i + 1 . ". " . $curl_result['report']['completed_test'][$i]['candidate_name'] . " & Score : " . $curl_result['report']['completed_test'][$i]['candidate_total_score'] . "<br>";
}
}
示例2: update_details_global
function update_details_global($contest, $contest_id, $contest_type, $cid)
{
//adding contest details
//creating object of api
echo "inside update global details ";
$provider = "hackerearth";
$api_table = new api_table();
$api = new api($api_table->get_api_url($provider), $api_table->get_client_id($provider), $api_table->get_client_secret($provider));
$json_data = $api->connect_api($contest_id);
//creating object of data for getting valuable information from json data
$data = new data();
$coders_size = $data->coders_participated($json_data);
echo $coders_size;
if ($coders_size == 0) {
die("Problem in connection with hackererth api : Reload to try again ");
}
//creating object of coders main table
//$coders = new coders();
//creating object of coders rating table
//$rating = new rating();
//check for tables if not present then create them
$candidate = new candidate_api($api_table->get_client_id($provider), $api_table->get_client_secret($provider));
$coders = new coders();
$rating = new rating();
//$res=$candidate->connect_api(11902,"harshitdd120@gmail.com");
//looping to add new coders details
$candidates_data = array();
$index = 0;
for ($i = 0; $i < $coders_size; $i++) {
$hacker_id = $data->hacker_id($json_data, $i);
$name = $data->name($json_data, $i);
$email = $data->email($json_data, $i);
$res = $candidate->connect_api($contest_id, $email);
$institute = $data->institute($res);
$pos1 = strpos($institute, "silchar");
$pos2 = strpos($institute, "sichar");
if ($pos1 != false || $pos2 != false) {
$candidates_data[$index]['hacker_id'] = $hacker_id;
$candidates_data[$index]['name'] = $name;
$index++;
echo 1 + $index . " " . $name . "<br>";
if (!$coders->is_coder_present($hacker_id)) {
$coders->add_new_coder($hacker_id, $name);
echo "new coder added " . $name . "<br>";
}
}
//if(!$coders->is_coder_present($hacker_id)){
// $coders->add_new_coder($hacker_id,$name);
//$rating->add_new_coder($hacker_id);
//echo "new coder added ".$name."<br>";
}
echo "<pre>";
print_r($candidates_data);
$rating_val = array();
for ($i = 0; $i < $index; $i++) {
$hacker_id = $candidates_data[$i]['hacker_id'];
$rate = $coders->get_final_rating($hacker_id);
$rating_val[$hacker_id] = $rate;
}
echo "<pre>";
print_r($rating_val);
//array storing new calculated seed values
$seed = seed($rating_val, $index, $coders);
echo "<pre>";
print_r($seed);
//array for storing new rating values
$new_rating = array();
for ($i = 0; $i < $index; $i++) {
$hacker_id = $candidates_data[$i]['hacker_id'];
$new_rating[$hacker_id] = new_rating($seed[$hacker_id], $i + 1, $contest_type, $rating_val[$hacker_id], $index);
}
echo "<pre>";
print_r($new_rating);
//adding a new column in coders rating table
//updating new rating for each participated contest
foreach ($new_rating as $key => $value) {
$uid = $coders->get_uid($key);
$coders->update_rating($key, $value);
$rating->insert_new_rating($cid, $uid, $value);
//echo "rating updated";
}
//updating new coders to old
$coders->new_to_old();
//updating that contest is evaluated
$contest->rate_contest($contest_id);
//header('Location:../pages/viewUsers.php');
}