function piRequest($code, $method) { global $verbose; // Requires auth checkAuth(); $code["function"] = "/" . str_replace(".", "/", $code["function"]); if ($verbose) { echo $code["function"] . "\n"; } $endpoint = endpointWith($code["function"], $method); if ($endpoint === false) { return json_encode(sendRequest($method, defaultHeader(), $code["arguments"], $code["function"])); //return false; } if ($method != "GET") { $data = formattedParametersWithData($endpoint, $data); } $newPath = fillEndpointPathWithRequirements($endpoint, $code["arguments"]); $code["arguments"] = cleanEndpointRequirementsFromData($endpoint, $code["arguments"]); return json_encode(sendRequest($method, defaultHeader(), $code["arguments"], $newPath)); }
function loginUser($client_secret, $client_id, $grant_type, $username = false, $password = false, $refresh_token = false, $response_type = false, $code = false, $redirect_uri = false) { $method = "POST"; $endpoint = endpointWith("/api/v1/token", $method); global $verbose; checkAuth(); $data = array("client_secret" => $client_secret, "client_id" => $client_id, "grant_type" => $grant_type, "username" => $username, "password" => $password, "refresh_token" => $refresh_token, "response_type" => $response_type, "code" => $code, "redirect_uri" => $redirect_uri); if ($method != "GET") { $data = formattedParametersWithData($endpoint, $data); } $newPath = fillEndpointPathWithRequirements($endpoint, $data); $data = cleanEndpointRequirementsFromData($endpoint, $data); return sendPOST(defaultHeader(), $data, $newPath); }