このドキュメントでは、Google Site Verification API の使用方法について説明します。
API の呼び出し
リクエストの形式
Google Site Verification API のオペレーションで説明されているように、サポートされているサイト確認オペレーションのほとんどは REST の HTTP 動詞(GET、POST、PUT、DELETE)に直接マッピングされています。
Google Site Verification API の URI の形式は次のとおりです。
https://www.googleapis.com/siteVerification/v1/webResource/resourceID?parameters
ここで、resourceID はウェブリソースの識別子、parameters はクエリに適用するパラメータです。実際に使用するパラメータは、実行するオペレーションによって異なります。また、OAuth 2.0 を使用している場合は、これらのパラメータに access_token を設定する必要があります。
リストクエリには resourceID が必要ないため、形式は次のようになります。
https://www.googleapis.com/siteVerification/v1/webResource?parametersgetToken オペレーションは、その固有の URI で呼び出すことができます。getToken の呼び出しの形式は次のとおりです。
https://www.googleapis.com/siteVerification/v1/token?parametersデータ形式
Google Site Verification API はデータを JSON 形式で返します。
JSON(JavaScript Object Notation)は言語に依存しない一般的なデータ フォーマットであり、任意のデータ構造を単純なテキスト形式で表示します。詳しくは json.org をご覧ください。
オペレーションの概要
次の表に示すように、Google Site Verification API ではコレクションとリソースに対して 6 つの異なるメソッドを呼び出すことができます。API の URL は https://www.googleapis.com/siteVerification/v1 を基準とします。
| オペレーション | 説明 | URL と構文 | 
|---|---|---|
| list | 認証されたユーザーのコレクション内のすべてのリソースを一覧表示します。 | 
 list リクエストの例をご覧ください。 | 
| insert | サイトまたはドメインを確認します。成功すると、新しいウェブリソースをユーザーのコレクションに挿入します。 リクエストの本文: ウェブリソースをご覧ください。 クエリ パラメータ:  | 
 insert リクエストの例をご覧ください。 | 
| get | 特定のウェブリソースの最新データを取得します。 | 
 get リクエストの例をご覧ください。 | 
| update | 特定のリソースのオーナーのリストを変更します。 リクエストの本文: ウェブリソースをご覧ください。 注: 
 | 
 update リクエストの例をご覧ください。 | 
| delete | ユーザーのコレクションからリソースを削除します(サイトがユーザーに属していることを確認しません)。 
 | 
 削除リクエストの例をご覧ください。 | 
| getToken | 認証されたユーザーのウェブサイトに配置する確認トークンを取得します。 リクエスト本文: 
 | 
 getToken リクエストの例をご覧ください。 | 
API 呼び出しの例
このセクションでは、初めて API を自分のテストデータを使って試す場合と同様に、開発者も認証済みユーザーであることを前提としています。
新しいサイトを確認する
サイトを確認するには
- まず、getToken を呼び出して確認トークンをリクエストします。
- 任意の方法でトークンをサイトに配置します。
- insert オペレーションを使用して、サイトがあなたのものであることを確認するよう Google に依頼します。
getToken(認証が必要)
POST https://www.googleapis.com/siteVerification/v1/token?access_token=oauth2-token
リクエスト:
POST https://www.googleapis.com/siteVerification/v1/token?access_token=oauth2-token
Content-Type: application/json
{
  "verificationMethod": "FILE",
  "site": {
    "identifier": "http://www.example.com",
    "type": "SITE"
  }
}対応:
{
  "token": "google12cfc68677988bb4.html",
  "method": "FILE"
}Insert(承認が必要)
POST https://www.googleapis.com/siteVerification/v1/webResource?verificationMethod=FILE&access_token=oauth2-token
リクエスト:
POST https://www.googleapis.com/siteVerification/v1/webResource?verificationMethod=FILE&access_token=oauth2-token
Content-Type: application/json
{
  "site": {
    "identifier": "http://www.example.com",
    "type": "SITE"
  }
}対応:
{
  "owners": [
    "myself@example.com",
  ],
  "id": "http%3A%2F%2Fwww.example.com%2F",
  "site": {
    "identifier": "http://www.example.com/",
    "type": "SITE"
  }
}
確認済みのウェブリソースの情報を取得する
確認済みのサイトとドメインの完全なリストを取得するには、list を呼び出します。1 つのウェブリソースの情報を取得するには、get を呼び出します。
List(承認が必要)
GET https://www.googleapis.com/siteVerification/v1/webResource?access_token=oauth2-token
リクエスト:
GET https://www.googleapis.com/siteVerification/v1/webResource?access_token=oauth2-token
対応:
{
  "items": [
    {
      "owners": [
        "myself@example.com",
      ],
      "id": "http%3A%2F%2Fwww.example.com%2F",
      "site": {
        "identifier": "http://www.example.com/site1",
        "type": "SITE"
      }
    },
    {
      "owners": [
        "myself@example.com",
      ],
      "id": "http%3A%2F%2Fwww.example.com%2F",
      "site": {
        "identifier": "http://www.example.com/site2",
        "type": "SITE"
      }
    }
  ]
}取得(承認が必要)
GET https://www.googleapis.com/siteVerification/v1/webResource/http%3A%2F%2Fwww.example.com%2F?access_token=oauth2-token
リクエスト:
GET https://www.googleapis.com/siteVerification/v1/webResource/http%3A%2F%2Fwww.example.com%2F?access_token=oauth2-token対応:
{
  "owners": [
    "myself@example.com",
  ],
  "id": "http%3A%2F%2Fwww.example.com%2F",
  "site": {
    "identifier": "http://www.example.com/",
    "type": "SITE"
  }
}確認情報を変更する
所有権の委任や取り消しを行うには、update を呼び出します。自分自身の所有権を削除するには、delete を呼び出します。
更新(承認が必要)
PUT https://www.googleapis.com/siteVerification/v1/webResource/http%3A%2F%2Fwww.example.com%2F?access_token=oauth2-token
リクエスト:
PUT https://www.googleapis.com/siteVerification/v1/webResource/http%3A%2F%2Fwww.example.com%2F?access_token=oauth2-token
Content-Type: application/json
{
  "owners": [
    "myself@example.com",
    "another@example.com",
  ],
  "id": "http%3A%2F%2Fwww.example.com%2F",
  "site": {
    "identifier": "http://www.example.com",
    "type": "SITE"
  }
}対応:
{
  "owners": [
    "myself@example.com",
    "another@example.com",
  ],
  "id": "http%3A%2F%2Fwww.example.com%2F",
  "site": {
    "identifier": "http://www.example.com/",
    "type": "SITE"
  }
}削除(承認が必要)
DELETE https://www.googleapis.com/siteVerification/v1/webResource/http%3A%2F%2Fwww.example.com%2F?access_token=oauth2-token
リクエスト:
DELETE https://www.googleapis.com/siteVerification/v1/webResource/http%3A%2F%2Fwww.example.com%2F?access_token=oauth2-token
対応:
成功を示す HTTP 204(コンテンツなし)ステータス コード。