Before you can make requests to the API, you must set up authorization. If you are using a client library, you must also create a Service
object.
The following code demonstrates how to configure your client and authorize requests using an API key.
Java
import com.google.api.client.http.HttpTransport; import com.google.api.client.http.javanet.NetHttpTransport; import com.google.api.client.json.jackson.JacksonFactory; import com.google.api.services.abusiveexperiencereport.v1.AbusiveExperienceReport; import com.google.api.services.abusiveexperiencereport.v1.AbusiveExperienceReportRequestInitializer; import com.google.api.services.abusiveexperiencereport.v1.model.SiteSummaryResponse; import com.google.api.services.abusiveexperiencereport.v1.model.ViolatingSitesResponse; ... public static void main(String[] args) { HttpTransport httpTransport = new NetHttpTransport(); JacksonFactory jsonFactory = new JacksonFactory(); AbusiveExperienceReportRequestInitializer reqInitializer = new AbusiveExperienceReportRequestInitializer("YOUR_API_KEY"); AbusiveExperienceReport service = new AbusiveExperienceReport.Builder(httpTransport, jsonFactory, null) .setAbusiveExperienceReportRequestInitializer(reqInitializer) .setApplicationName("YOUR_APPLICATION_NAME") .build(); ViolatingSitesResponse response = service.violatingSites().list().execute(); ... } ...
Python
from apiclient.discovery import build api_key = 'YOUR_API_KEY' service = build('abusiveexperiencereport', 'v1', developerKey=api_key) response = service.violatingSites().list().execute() ...
PHP
$client = new Google_Client(); $client->setApplicationName("YOUR_APPLICATION_NAME"); $client->setDeveloperKey("YOUR_API_KEY"); $service = new Google_Service_AbusiveExperienceReport($client); $response = $service->violatingSites; ...
.NET
using Google.Apis.AbusiveExperienceReport.v1.AbusiveExperienceReportService; using Google.Apis.Services.BaseClientService.Initializer; ... public static void Main(string[] args) { var service = new AbusiveExperienceReportService(new BaseClientService.Initializer { ApplicationName = "YOUR_APPLICATION_NAME", ApiKey = "YOUR_API_KEY", }); var response = await service.ViolatingSites.List().ExecuteAsync(); ... }