/**
  * Returns welcome message
  * @return string welcome message
  */
 public static function unsubscribe($courseid)
 {
     global $USER, $DB;
     $params = self::validate_parameters(self::unsubscribe_parameters(), array('courseid' => $courseid));
     $REST_URL = block_moodlefolder_external::get_api_url();
     $context = context_user::instance($USER->id);
     self::validate_context($context);
     $result = CallAPI('POST', $REST_URL . 'removeUserFromCourse', array('courseid' => $courseid, 'userid' => $USER->username));
     $DB->delete_records('moodlefolder', array('username' => $USER->username, 'courseid' => $params['courseid']), false);
     return 'User ' . $USER->username . ' was removed from course ' . $params['courseid'] . '. Result: ' . $result;
 }
Example #2
2
    $status = 'success';
} else {
    echo "<b>Card Declined</b> (" . $tran->result . ")<br>";
    echo "<b>Reason:</b> " . $tran->error . "<br>";
    if (@$tran->curlerror) {
        echo "<b>Curl Error:</b> " . $tran->curlerror . "<br>";
    }
    $status = 'error';
}
//set data for PUT request
$bodyparams = array("client_id" => "pMSbMB2b9WqPiv2FILcIbeuJW20E7xLLKS5SAaRh", "client_secret" => "JlAxg0NynNJlnhvngMnto9n8WvmKIaYWocSchiYG", "status" => $status);
//sends the PUT request to the Paydunk API
function CallAPI($method, $url, $data = false)
{
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_PUT, 1);
    $update_json = json_encode($data);
    curl_setopt($curl, CURLOPT_URL, $url . "?" . http_build_query($data));
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_SSLVERSION, 4);
    $result = curl_exec($curl);
    $api_response_info = curl_getinfo($curl);
    curl_close($curl);
    return $result;
}
//get the transaction_uuid from Paydunk & call the the Paydunk API
$transaction_uuid = $_POST['transaction_uuid'];
if (isset($transaction_uuid)) {
    $url = "https://api.paydunk.com/api/v1/transactions/" . $transaction_uuid;
    CallAPI("PUT", $url, $bodyparams);
}
Example #3
0
function myFunction($link)
{
    $header = getToken();
    $res = CallAPI('GET', $link, false, $header);
    $var = json_decode($res);
    $path = dirname(__FILE__) . "/files/";
    $file = $path . "Page_" . $var->paging->currentPage . ".json";
    echo $file;
    echo $var->paging->currentPage;
    file_put_contents($file, json_encode($var->list));
    //@todo put logs here $var->paging->next
    file_put_contents('script.log', "link: " . $var->paging->next . " Page: " . $var->paging->currentPage . "\n", FILE_APPEND);
    if ($var->paging->currentPage != $var->paging->totalPage) {
        echo $var->paging->next;
        myFunction($var->paging->next);
    }
}
        case "PUT":
            curl_setopt($curl, CURLOPT_PUT, 1);
            break;
        default:
            if ($data) {
                $url = sprintf("%s?%s", $url, http_build_query($data));
            }
    }
    if ($username != '') {
        curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
        curl_setopt($curl, CURLOPT_USERPWD, $username . ":" . $password);
    }
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    return curl_exec($curl);
}
$data = false;
$remote = true;
if ($remote) {
    $url = 'https://bobersvg2pdf.comcode.si/index.php/api/convert/20';
} else {
    $url = 'http://svg2pdf.bober/index.php/api/convert';
}
$response = CallAPI('GET', $url, $data, 'admin', 'admin');
echo $response;
$response = json_decode($response, true);
if (isset($response['result']) && $response['result'] != null && $response['result'] != '') {
    file_put_contents(dirname(__FILE__) . '/out.pdf', base64_decode($response['result']));
}
Example #5
0
function postOnAPI($url, $params)
{
    $result = CallAPI("POST", $url, $params);
    echo $result;
}
    $curl = curl_init();
    switch ($method) {
        case "POST":
            curl_setopt($curl, CURLOPT_POST, 1);
            if ($data) {
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
            }
            break;
        case "PUT":
            curl_setopt($curl, CURLOPT_PUT, 1);
            break;
        default:
            if ($data) {
                $url = sprintf("%s?%s", $url, http_build_query($data));
            }
    }
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($curl);
    curl_close($curl);
    return $result;
}
if (isset($_POST["author"])) {
    $author = $_POST["author"];
    $author = rawurlencode($author);
    $epmc_url = 'http://www.ebi.ac.uk/europepmc/webservices/rest/search/query=' . $author . '&pageSize=1000';
}
$data = CallAPI('GET', $epmc_url, false);
$xml = simplexml_load_string($data) or die("Error: Cannot create object");
$json = json_encode($xml);
print_r($json);
Example #7
0
if (!empty($apiResult)) {
    insertRows($conn, $apiResult);
    echo "data logged!\r\n";
    $apiResult = false;
} else {
    echo "No Data! ";
    print_r($fromDate);
    echo "\r\n";
}
// Checks current day in script vs acutal day
$checkDate = strtotime($fromDate['year'] . '-' . $fromDate['month'] . '-' . $fromDate['day'] . 'T' . $fromDate['hour'] . ":00:00");
$dayDate = strtotime($date['year'] . '-' . $date['mon'] . '-' . $date['mday'] . 'T' . "00:00:00");
while ($checkDate < $dayDate) {
    // Sanity check, really just helps keep my code clean for me
    if ($checkDate < $dayDate) {
        $apiResult = CallAPI($fromDate);
        if (!empty($apiResult)) {
            insertRows($conn, $apiResult);
            echo "data logged!\r\n";
            $apiResult = false;
        } else {
            var_dump(CallAPI($fromDate));
            echo "No Data! ";
            print_r($fromDate);
            echo "\r\n";
        }
    }
    // Goes to the next day and reformats the checkDate
    $fromDate = IncrementDate($fromDate);
    $checkDate = strtotime($fromDate['year'] . '-' . $fromDate['month'] . '-' . $fromDate['day'] . 'T' . $fromDate['hour'] . ":00:00");
}
Example #8
0
            curl_setopt($curl, CURLOPT_PUT, 1);
            break;
        default:
            if ($data) {
                $url = sprintf("%s?%s", $url, http_build_query($data));
            }
    }
    if ($username != '') {
        curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
        curl_setopt($curl, CURLOPT_USERPWD, $username . ":" . $password);
    }
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    return curl_exec($curl);
}
$data = array();
$remote = true;
if ($remote) {
    $url = 'https://bobersvg2pdf.comcode.si/index.php/api/convert';
} else {
    $url = 'http://svg2pdf.bober/index.php/api/convert';
}
$data['svg'] = base64_encode(file_get_contents(dirname(__FILE__) . '/../bober-template.svg'));
$data_list = array(array('###IME_IN_PRIIMEK###' => 'Dean Gostiša'), array('###IME_IN_PRIIMEK###' => 'Janez Novak'), array('###IME_IN_PRIIMEK###' => 'Dean Gostiša'), array('###IME_IN_PRIIMEK###' => 'Janez Novak'), array('###IME_IN_PRIIMEK###' => 'Dean Gostiša'), array('###IME_IN_PRIIMEK###' => 'Janez Novak'), array('###IME_IN_PRIIMEK###' => 'Dean Gostiša'), array('###IME_IN_PRIIMEK###' => 'Janez Novak'), array('###IME_IN_PRIIMEK###' => 'Dean Gostiša'), array('###IME_IN_PRIIMEK###' => 'Janez Novak'), array('###IME_IN_PRIIMEK###' => 'Dean Gostiša'), array('###IME_IN_PRIIMEK###' => 'Janez Novak'), array('###IME_IN_PRIIMEK###' => 'Dean Gostiša'), array('###IME_IN_PRIIMEK###' => 'Janez Novak'), array('###IME_IN_PRIIMEK###' => 'Dean Gostiša'), array('###IME_IN_PRIIMEK###' => 'Janez Novak'), array('###IME_IN_PRIIMEK###' => 'Dean Gostiša'), array('###IME_IN_PRIIMEK###' => 'Janez Novak'), array('###IME_IN_PRIIMEK###' => 'Dean Gostiša'), array('###IME_IN_PRIIMEK###' => 'Janez Novak'), array('###IME_IN_PRIIMEK###' => 'Dean Gostiša'), array('###IME_IN_PRIIMEK###' => 'Janez Novak'), array('###IME_IN_PRIIMEK###' => 'Dean Gostiša'), array('###IME_IN_PRIIMEK###' => 'Janez Novak'), array('###IME_IN_PRIIMEK###' => 'Dean Gostiša'), array('###IME_IN_PRIIMEK###' => 'Janez Novak'), array('###IME_IN_PRIIMEK###' => 'Dean Gostiša'), array('###IME_IN_PRIIMEK###' => 'Janez Novak'), array('###IME_IN_PRIIMEK###' => 'Dean Gostiša'), array('###IME_IN_PRIIMEK###' => 'Janez Novak'), array('###IME_IN_PRIIMEK###' => 'Dean Gostiša'), array('###IME_IN_PRIIMEK###' => 'Janez Novak'), array('###IME_IN_PRIIMEK###' => 'Dean Gostiša'), array('###IME_IN_PRIIMEK###' => 'Janez Novak'), array('###IME_IN_PRIIMEK###' => 'Dean Gostiša'), array('###IME_IN_PRIIMEK###' => 'Janez Novak'), array('###IME_IN_PRIIMEK###' => 'Dean Gostiša'), array('###IME_IN_PRIIMEK###' => 'Janez Novak'));
$data['data'] = json_encode($data_list);
$data['data_type'] = 'json';
$data['background'] = 1;
echo CallAPI('POST', $url, $data, 'admin', 'admin');
Example #9
0
function GetImageSearchResponse($cmd)
{
    $googleImageSearch = "http://ajax.googleapis.com/ajax/services/search/images?v=1.0&safe={$cmd->Safe}&as_filetype={$cmd->FileType}&rsz={$cmd->Count}&imgsz={$cmd->Size}&q={$cmd->Query}";
    $result = CallAPI($googleImageSearch);
    return $result;
}
Example #10
0
function get_user_frankly_id($username)
{
    $response = CallAPI('GET', "http://api.frankly.me/user/profile/" . $username);
    $dat = json_decode($response, true);
    #print_r ($dat);
    return $dat['user']['id'];
}
Example #11
0
        $server = $server . '/' . $sessionId;
        $result = CallAPI('POST', $server, $data);
        echo $result;
        break;
    case 'sendMessage':
        if ($jsep == '') {
            $request = '{"janus": "message", "body": ' . $message . ', "transaction": "' . generateRandomString() . '","apisecret":"' . $password . '"}';
        } else {
            $request = '{"janus": "message", "body": ' . $message . ', "transaction": "' . generateRandomString() . '","jsep":' . $jsep . ',"apisecret":"' . $password . '"}';
        }
        //	echo $request;
        $server = $server . '/' . $sessionId . '/' . $handleId;
        $result = CallAPI('POST', $server, $request);
        echo $result;
        break;
    case 'sendTrickleCandidate':
        $request = '{"janus": "trickle", "candidate": ' . $candidate . ', "transaction": "' . generateRandomString() . '","apisecret":"' . $password . '"}';
        $server = $server . '/' . $sessionId . '/' . $handleId;
        $result = CallAPI('POST', $server, $request);
        echo $result;
        break;
    case 'destroyHandle':
        $request = '{"janus":"detach","transaction":"' . generateRandomString() . '","apisecret":"' . $password . '"}';
        $server = $server . '/' . $sessionId . '/' . $handleId;
        $result = CallAPI('POST', $server, $request);
        echo $result;
        break;
        break;
    default:
        die;
}
Example #12
0
function lookupBook()
{
    global $slimApp;
    $conn = dbConnect();
    $request = $slimApp->request();
    $body = $request->getBody();
    $input = json_decode($body);
    $ISBN = $input->ISBN;
    try {
        $ISBN = (string) $ISBN;
        $URL = "http://isbndb.com/api/v2/json/4UYZ2W9Z/book/" . $ISBN;
        $response = CallAPI("GET", $URL);
        echo $response;
        //echo json_encode($response);
    } catch (Exception $e) {
        echo $e->getMessage();
    }
}
        default:
            if ($data) {
                $url = sprintf("%s?%s", $url, http_build_query($data));
            }
    }
    // Optional Authentication:
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($curl);
    curl_close($curl);
    return $result;
}
$StudyList = json_decode(CallAPI('GET', 'http://www.ebi.ac.uk/metabolights/webservice/study/list'), true);
foreach ($StudyList['content'] as $study) {
    $StudyDetails = json_decode(CallAPI('GET', 'http://www.ebi.ac.uk/metabolights/webservice/study/' . $study), true);
    $releaseDate = $StudyDetails['content']['studyPublicReleaseDate'];
    $current = strtotime(date("Y-m-d"));
    $date = strtotime($releaseDate);
    $datediff = $date - $current;
    $difference = floor($datediff / (60 * 60 * 24));
    if ($difference == 0) {
        var_dump('Today-' . $study);
        $code = $tmhOAuth->user_request(array('method' => 'POST', 'url' => $tmhOAuth->url('1.1/statuses/update'), 'params' => array('status' => $study . ': ' . $StudyDetails['content']['title'] . ' http://www.ebi.ac.uk/metabolights/' . $study)));
        $tmhOAuth->render_response();
    } else {
        if ($difference > 1) {
            var_dump('Future-' . $study);
        } else {
            var_dump('Published-' . $study);
        }
Example #14
0
            if ($data) {
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
            }
            break;
        case "PUT":
            curl_setopt($curl, CURLOPT_PUT, 1);
            break;
        default:
            if ($data) {
                $url = sprintf("%s?%s", $url, http_build_query($data));
            }
    }
    // Optional Authentication:
    //curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    //curl_setopt($curl, CURLOPT_USERPWD, "username:password");
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($curl);
    curl_close($curl);
    return $result;
}
$template = '';
if (isset($_GET['c']) && !empty($_GET['c'])) {
    $character = json_decode(CallAPI('GET', 'http://eu.battle.net/api/wow/character/illidan/' . $_GET['c'], array("fields" => "items")));
    $template .= '<h1>' . $character->name . '</h1>';
    $template .= '<p>ilvl : ' . $character->items->averageItemLevelEquipped . '</h1>';
    $template .= '<p>t&ecirc;te : <a href="#" rel="item=' . $character->items->head->id . ';class=brewmaster;domain=fr;bonus=567;">' . $character->items->head->name . '</a></h1>';
    $template .= '<p>cou : <a href="#" rel="item=' . $character->items->neck->id . ';domain=fr;bonus=567;">' . $character->items->neck->name . '</a></h1>';
} else {
    $template = 'Personnage inconnu';
}
Example #15
0
 function getSummonerInfo($pseudo)
 {
     $ret = CallAPI('GET', $this->base_url . '/api/lol/' . $this->region . '/v1.4/summoner/by-name/' . $pseudo . $this->apiKeyAsParam());
     return $ret;
 }
    $url = $baseApiURL . $filters;
    $method = 'GET';
    $responseAPI = CallAPI($method, $url);
    $redirectURL = "http://domainone.local/domainonelogin.php";
    header('Location:' . $redirectURL);
    $message = "You have logged out successfully <br><br> <a href='" . $redirectURL . "'>Click to Login</a>";
    exit;
} else {
    if (!empty($_COOKIE['ssotoken'])) {
        $id = $_COOKIE['ssoid'];
        $token = $_COOKIE['ssotoken'];
        $baseApiURL = 'http://localhost/login/web/app_dev.php/api/users';
        $filters = "?filters[token]={$token}";
        $method = 'GET';
        $url = $baseApiURL . $filters;
        $responseAPI = CallAPI($method, $url);
        if (empty($responseAPI)) {
            $redirectURL = "http://domainone.local/domainonelogin.php";
            header('Location:' . $redirectURL);
        }
    } else {
        $redirectURL = "http://domainone.local/domainonelogin.php";
        header('Location:' . $redirectURL);
    }
    echo "I have successfully login to domain one<br><br> <a href='?logout=" . $id . "'>Logout</a>";
}
/*
 * Function
 * Call Api is the common function called for the API, for POST, PUT and get method
 * @input param: Method (GET, PUT, POST), URL, Data in array format
 * @output: Json string
Example #17
0
            break;
        case "PUT":
            curl_setopt($curl, CURLOPT_PUT, 1);
            break;
        default:
            if ($data) {
                $url = sprintf("%s?%s", $url, http_build_query($data));
            }
    }
    // Optional Authentication:
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($curl, CURLOPT_USERPWD, "username:password");
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($curl);
    curl_close($curl);
    return $result;
}
$json = CallAPI('json', 'http://localhost:8080/jwt/wservice.php?user=vrish&num=10&format=json', $data = false);
require_once "JWT.php";
$header = '{"typ":"JWT", "alg":"HS256"}';
//secret key
$key = '46196053844814367107123';
$JWT = new JWT();
//encoding the json result in to json token
$token = $JWT->encode($header, $json, $key);
//decoding the json token
$decoded_json = $JWT->decode($token, $key);
echo '<strong>Endoded token: </strong>' . $token;
//decoding the json token
echo '<strong>JWT Decoded: </strong>' . $decoded_json;
function GetLandinfoForLandCover($type, $recorderName)
{
    $aggregatedData = array();
    $outputFilter = urlencode("latitude,longitude,test_plot,organization");
    $landpks_API_URL = str_replace("%object%", "landinfo_landcover", $GLOBALS['landpks_API_URL_BASE']);
    $landpks_API_URL = str_replace("%type%", $type, $landpks_API_URL);
    $landpks_API_URL = str_replace("%recorder_name%", $recorderName, $landpks_API_URL);
    $landpks_API_URL = $landpks_API_URL . "&output_filter=" . $outputFilter;
    $landpks_API_URL = $landpks_API_URL . "&count=1000";
    $output = CallAPI('', $landpks_API_URL);
    while (true) {
        if (isset($output->data)) {
            $aggregatedData = array_merge($aggregatedData, $output->data);
            if (count($output->data) === 0) {
                return $aggregatedData;
            } else {
                if ($output->search_metadata->has_next === false || $output->search_metadata->has_next === 'false' || $output->search_metadata->next_cursor === 0) {
                    return $aggregatedData;
                } else {
                    try {
                        $output = CallAPI($output->search_metadata->next_cursor, $landpks_API_URL);
                    } catch (Exception $e) {
                        $GLOBALS['errorMessage'] = $e->getMessage();
                        break;
                    }
                }
            }
        } else {
            break;
        }
    }
    return $aggregatedData;
}
Example #19
0
<?php

require_once dirname(dirname(__FILE__)) . '/models/config.php';
$reports = json_decode(CallAPI("GET", "https://people.cs.clemson.edu/~jacksod/api/v1/reports?filter=new"), true)['data'];
//expand report location and person to show details, not just ID
if (is_array($reports)) {
    for ($i = 0; $i < count($reports); $i++) {
        $person = new Person();
        $person->fetch($reports[$i]['personID']);
        $reports[$i]['personKind'] = $person->getPersonKindName();
        $reports[$i]['personName'] = $person->getName();
        $reports[$i]['personUsername'] = $person->getUsername();
        $reports[$i]['personPhone'] = $person->getPhone();
        $location = new Location();
        $location->fetch($reports[$i]['locationID']);
        $reports[$i]['locationBuilding'] = $location->getBuildingName();
        $reports[$i]['locationRoom'] = $location->getRoom();
    }
}
//var_dump($reports);
?>


<?php 
include 'header.php';
?>
<!-- in .container div -->

<div class='row'>
	<div class='col-sm-12'>
		<div class="page-header">
Example #20
0
function FindDefect($id)
{
    $query = GetDefectQueryUri($id);
    $searchresult = CallAPI($query);
    $count = GetCount($searchresult);
    if ($count == 0) {
        NotFound($id);
    }
    return GetFirstObjectFromSearchResult("Defect", $searchresult);
}
    switch ($method) {
        case "POST":
            curl_setopt($curl, CURLOPT_POST, 1);
            if ($data) {
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
            }
            break;
        case "PUT":
            curl_setopt($curl, CURLOPT_PUT, 1);
            if ($data) {
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
            }
            break;
        default:
            if ($data) {
                $url = sprintf("%s?%s", $url, http_build_query($data));
            }
    }
    // Optional Authentication:
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($curl, CURLOPT_USERPWD, "username:password");
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($curl);
    curl_close($curl);
    return $result;
}
//===========================================================
//=how to call service -------------
CallAPI("GET", OPERATIONS_SERVICES_BASE_URL . "drivers/{$driver_id}");