このドキュメントでは、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?parameters
固有の一意の URI を使用して getToken オペレーションを呼び出すことができます。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 リクエストの例をご覧ください。 |
get | 特定のウェブリソースの最新データを取得します。 |
get リクエストの例をご覧ください。 |
update | 特定のリソースの所有者のリストを変更します。 リクエストの本文: ウェブリソースをご覧ください。 注:
|
update リクエストの例をご覧ください。 |
delete | ユーザーのコレクションからリソースを削除します(サイトがユーザーに属することを確認します)。
|
削除リクエストの例をご覧ください。 |
getToken を使用します。 | 認証済みユーザーのウェブサイトに配置する確認トークンを取得します。 リクエスト本文:
|
getToken リクエストの例をご覧ください。 |
API 呼び出しの例
このセクションでは、デベロッパーが独自のテストデータを使用して API を初めて試す場合のように、デベロッパーとデベロッパーが認証済みユーザーであることを前提としています。
新しいサイトの確認
サイトの所有権を証明するには、
- まず、getToken を呼び出して確認トークンをリクエストします。
- 選択した方法で、サイトにトークンを配置します。
- 挿入操作を使用して、サイトがご自身のものであることを 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" }
挿入(承認が必要)
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 を呼び出します。
リスト(認証が必要)
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(認証が必要)
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(コンテンツなし)ステータス コード。