public static function Get($url) { $http_request = new HttpRequest(); $http_request->setTargetUrl($url)->setHeader('application-id', Backendless::getApplicationId())->setHeader('secret-key', Backendless::getSecretKey())->setHeader('application-type', 'REST')->setHeader('Accept:', '*/*')->setHeader('Content-Type', 'application/json'); foreach (self::$headers as $heder_n => $h_val) { $http_request->setHeader($heder_n, $h_val); } self::addUserTokenHeader($http_request); self::$headers = []; $http_request->request('', 'GET'); self::handleError($http_request); return $http_request->getResponse(); }
public function copyFile($source_path_name, $target_path) { $source_path_name = trim($source_path_name); $source_path_name = trim($source_path_name, "\\\\/"); $target_path = trim($target_path); $target_path = trim($target_path, "\\\\/"); $url_part = Backendless::getUrl() . "/" . Backendless::getApplicationId() . "/" . Backendless::getVersion(); $request_body = ["sourcePath" => $source_path_name, "targetPath" => $target_path]; return RequestBuilder::doRequest('files', 'copy', $request_body, 'PUT'); }
private function runAction($action_name, $geofence_name, $geopoint = null) { $url = "fence/" . $action_name . "?geoFence=" . $geofence_name; $headers = []; $headers['application-id'] = Backendless::getApplicationId(); $headers['secret-key'] = Backendless::getSecretKey(); $headers['application-type'] = 'REST'; $geopoint_data = []; if ($geopoint !== null) { if (is_object($geopoint)) { $geopoint_data['latitude'] = $geopoint->getLatitude(); $geopoint_data['longitude'] = $geopoint->getLongitude(); } else { $geopoint_data = $geopoint; } $headers['Content-Type'] = 'application/json'; } else { $geopoint_data = null; } return RequestBuilder::doRequestWithHeaders("geo", $url, $geopoint_data, "POST", $headers)["totalObjects"]; }