コード例 #1
0
 public static function doRequestWithHeaders($service = null, $action = null, $data_array = null, $method = "POST", $headers = [])
 {
     $url = Backendless::getUrl() . '/' . Backendless::getVersion();
     if ($service !== null) {
         $url .= '/' . $service;
     }
     if ($action !== null) {
         $url .= '/' . $action;
     }
     $http_request = new HttpRequest();
     $http_request->setTargetUrl($url)->setHeader('application-id', Backendless::getApplicationId())->setHeader('secret-key', Backendless::getSecretKey());
     foreach ($headers as $name => $val) {
         $http_request->setHeader($name, $val);
     }
     foreach (self::$headers as $heder_n => $h_val) {
         $http_request->setHeader($heder_n, $h_val);
     }
     self::addUserTokenHeader($http_request);
     self::$headers = [];
     $http_request->request(json_encode($data_array), $method);
     self::handleError($http_request);
     return json_decode($http_request->getResponse(), true);
 }
コード例 #2
0
ファイル: Messaging.php プロジェクト: Backendless/PHP-SDK
 public function sendEmail($subject, $body, $to, $attachments = null, $html)
 {
     if (!is_array($to)) {
         $to = [$to];
     }
     $data = ["subject" => $subject, "to" => $to];
     if ($html) {
         $data["bodyparts"] = ["htmlmessage" => $body];
     } else {
         $data["bodyparts"] = ["textmessage" => $body];
     }
     if ($attachments !== null) {
         $data["attachment"] = $attachments;
     }
     return RequestBuilder::doRequestByUrl(Backendless::getUrl() . "/" . Backendless::getVersion() . "/messaging/email", $data, 'POST');
 }
コード例 #3
0
ファイル: Files.php プロジェクト: BionicClick/PHP-SDK
 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');
 }
コード例 #4
0
ファイル: Counters.php プロジェクト: Backendless/PHP-SDK
 public function reset($counter_name)
 {
     RequestBuilder::doRequestByUrl(Backendless::getUrl() . "/" . Backendless::getVersion() . "/counters/" . $counter_name . "/reset", '', 'PUT');
 }
コード例 #5
0
ファイル: Cache.php プロジェクト: Backendless/PHP-SDK
 public function expireAt($key, $timestamp)
 {
     $timestamp = $timestamp * 1000;
     RequestBuilder::doRequestByUrl(Backendless::getUrl() . "/" . Backendless::getVersion() . "/cache/" . $key . "expireAt?timestamp=" . $timestamp, '', 'PUT');
 }
コード例 #6
0
ファイル: Events.php プロジェクト: Backendless/PHP-SDK
 public function dispatch($event_name, $event_args_array = null)
 {
     return RequestBuilder::doRequestByUrl(Backendless::getUrl() . "/" . Backendless::getVersion() . "/servercode/events/" . $event_name, $event_args_array, 'POST');
 }