LoginSignup
1
1

More than 3 years have passed since last update.

PHP の Rest で Cloud Firestore のデータを削除 (Delete)

Posted at
firestore_delete_rest.php
#! /usr/bin/php
<?php
//
//  firestore_delete_rest.php
//
//                  Feb/16/2020
//
// ------------------------------------------------------------------
include('Requests/library/Requests.php');
include("get_token.php");
//
// ------------------------------------------------------------------

// ------------------------------------------------------------------
fputs (STDERR,"*** 開始 ***\n");
Requests::register_autoloader();
//
$key_in = $argv[1];
print($key_in . "\n");

$token = get_token_proc();
//
$project = 'project-jan25-2020';
$headers = array('Authorization' => 'Bearer ' . $token);
$options = array();
$url_base = "https://firestore.googleapis.com/v1/projects/" . $project . "/databases/(default)/documents/cities";
$url = $url_base . "/" . $key_in;

$request = Requests::delete($url, $headers);
var_dump($request->status_code);

$rvalue = $request->body;

print($rvalue);

fputs (STDERR,"*** 終了 ***\n");
// ------------------------------------------------------------------
?>

get_token.py はこちら
PHP の Rest で Cloud Firestore のデータを作成 (Create)

実行コマンド

export GOOGLE_APPLICATION_CREDENTIALS="***.json"
./firestore_delete_rest.php t0922
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1