सिंक्रोनस अनुरोध

Search Ads 360 Reporting API का नया वर्शन अब उपलब्ध है. नए एपीआई से कस्टम रिपोर्ट बनाने और डेटा को रिपोर्टिंग ऐप्लिकेशन में इंटिग्रेट करने की बेहतर सुविधा और प्रक्रियाएं शामिल हैं. Search Ads 360 के नए वर्शन की रिपोर्टिंग पर माइग्रेट करने और उसका इस्तेमाल करने के बारे में ज़्यादा जानें एपीआई.

अगर विज्ञापन देने वाले लोगों या कंपनियों या इंजन खाते की रिपोर्ट को छोटे साइज़ से मॉडरेट करने का अनुरोध किया जा रहा है, तो सिंक्रोनस रिपोर्ट का सिर्फ़ एक अनुरोध भेजें. अनुरोध के जवाब में, Search Ads 360 API पूरी रिपोर्ट को JSON ऑब्जेक्ट में दिखाएगा. सिंक्रोनस अनुरोध:

  • सिर्फ़ विज्ञापन देने वाले व्यक्ति या कंपनी को वापस किया जा सकता है और इंजन खाते की रिपोर्ट
  • अपने क्लाइंट को तब तक ब्लॉक करें, जब तक Search Ads 360 की रिपोर्ट जनरेट नहीं हो जाती

अगर विज्ञापन देने वाले बड़े लोगों या कंपनियों या इंजन-खाता रिपोर्ट का अनुरोध किया जा रहा है, तो हमारा सुझाव है कि आप एसिंक्रोनस अप्रोच.

सिंक्रोनस अनुरोध करने का तरीका

Reports.generate() पर कॉल करो का इस्तेमाल करें. इससे विज्ञापन देने वाले या इंजन खाते की रिपोर्ट में, आपको किस तरह का डेटा चाहिए.

Search Ads 360, अनुरोध की पुष्टि करता है, रिपोर्ट जनरेट करता है, और जवाब का मुख्य हिस्सा.

सिंक्रोनस अनुरोध का उदाहरण

यह Reports.generate() का उदाहरण है अनुरोध.

JSON

POST  https://www.googleapis.com/doubleclicksearch/v2/reports/generate
Authorization: Bearer your OAuth 2.0 access token
Content-type: application/json

{
  "reportScope": {
    "agencyId": "12300000000000456", // Replace with your ID
    "advertiserId": "21700000000011523", // Replace with your ID
    "engineAccountId": "700000000073991" // Replace with your ID
  },
  "reportType": "account",              // This report covers all revenue and visits in the
                                        // engine account specified in reportScope.
  "columns": [
    { "columnName": "date" },           // The date column segments the report by individual days.

    { "columnName": "dfaRevenue" },     // Here are some metric columns available for keyword
    {                                   // reports.
      "columnName": "visits",
      "startDate": "2013-01-01",        // Each metric column can optionally specify its own start 
      "endDate": "2013-01-31",          // and end date; by default the report timeRange is used.
      "headerText": "January visits"    // Every column can optionally specify a headerText, which
                                        // changes the name of the column in the report.
    }
  ],
  "timeRange" : {
    "startDate" : "2012-05-01",         // Dates are inclusive and specified in YYYY-MM-DD format.
    "endDate" : "2013-05-01"

    // Alternatively, try the "changedMetricsSinceTimestamp" or "changedAttributesSinceTimestamp"
    // options. See Incremental reports.

  },
  "statisticsCurrency": "agency",       // Required. See Currency for statistics.
  "verifySingleTimeZone": false,        // Optional. Defaults to false. See Time zone.
  "includeRemovedEntities": false           // Optional. Defaults to false.
}
        

Java

  public static void main(String[] args) throws Exception {
    Doubleclicksearch service = getService(); // See Set Up Your Application.
    Report report = generateAccountReport(service);
    outputReport(report, "./");
  }

  /**
   * Creates an account report using the synchronous Report.generate method.
   *
   * @throws IOException
   */
  private static Report generateAccountReport(Doubleclicksearch service) throws IOException {
    try {
      return service.reports().generate(generateAccountRequest()).execute();
    } catch (GoogleJsonResponseException e) {
      System.err.println("Report request was rejected.");
      for (ErrorInfo error : e.getDetails().getErrors()) {
        System.err.println(error.getMessage());
      }
      System.exit(e.getStatusCode());
      return null; // Unreachable code.
    }
  }

  /**
   * Creates a simple static request that lists the clicks and visits for an engine account. Use
   * your own agency ID, advertiser ID, and engine account ID.
   */
  private static ReportRequest generateAccountRequest() {
    return new ReportRequest().setReportScope(
      new ReportScope()
        .setAgencyId(20700000000000451L) // Replace with your ID
        .setAdvertiserId(21700000000010391L) // Replace with your ID
        .setEngineAccountId(700000000042201L)) // Replace with your ID
        .setReportType("account")
        .setColumns(Arrays.asList(new ReportApiColumnSpec[] {
            new ReportApiColumnSpec().setColumnName("date"),
            new ReportApiColumnSpec().setColumnName("dfaRevenue"),
            new ReportApiColumnSpec()
                .setColumnName("visits")
                .setHeaderText("January visits")
                .setStartDate("2013-01-01")
                .setEndDate("2013-01-31"),}))
        .setTimeRange(new TimeRange()
          .setStartDate("2012-05-01")
          .setEndDate("2013-05-01"))
        .setStatisticsCurrency("agency");
  }

  /**
   * Outputs a synchronous report to a file.
   */
  private static void outputReport(Report report, String localPath)
      throws IOException {
    FileOutputStream outputStream = new FileOutputStream(new File(localPath, "Report"));
    final PrintStream printStream = new PrintStream(outputStream);
    printStream.print(report);
    printStream.close();
  }
        

Python

def generate_report(service):
  """Generate and print sample report.

  Args:
    service: An authorized Doubleclicksearch service.  See Set Up Your Application.
  """
  request = service.reports().generate(
      body=
      {
        "reportScope
            "agencyId": "12300000000000456", // Replace with your ID
            "advertiserId": "21700000000011523", // Replace with your ID
            "engineAccountId": "700000000073991" // Replace with your ID
            },
        "reportType": "account",
        "columns": [
            { "columnName": "date" },
            { "columnName": "dfaRevenue" },
            {
              "columnName": "visits",
              "startDate": "2013-01-01",
              "endDate": "2013-01-31",
              "headerText": "January visits"
             }
        ],
        "timeRange" : {
            "startDate" : "2012-05-01",
            "endDate" : "2013-05-01"
        },
        "statisticsCurrency": "agency",
        "verifySingleTimeZone": "false",
        "includeRemovedEntities": "false"
        }
  )

  pprint.pprint(request.execute())

उदाहरण के तौर पर दी गई रिपोर्ट

सिंक किए गए अनुरोध का रिस्पॉन्स, रिपोर्ट ऑब्जेक्ट होता है. अगर अनुरोध की पुष्टि हो गई है, तो ऑब्जेक्ट की पहली कुछ प्रॉपर्टी में ऐसा मेटाडेटा होता है जो आपके सबमिट किए गए अनुरोध के बारे में बताता है. रिपोर्ट, ऑब्जेक्ट के rows में है प्रॉपर्टी.

{
  "kind":"doubleclicksearch#report",
  "request":{
    "columns":[
      {"columnName":"date"},
      {"columnName":"dfaRevenue"},
      {"columnName":"visits","endDate":"2013-01-31","headerText":"visits last month","startDate":"2013-01-01"}
    ],
    "includeDeletedEntities":false,
    "reportScope":{
      "agencyId":"12300000000000456",
      "advertiserId":"21700000000011523",
      "engineAccountId":"700000000073991"
     },
    "reportType":"account",
    "rowCount":10000,
    "startRow":0,
    "statisticsCurrency":"agency",
    "timeRange":{
      "endDate":"2013-05-01",
      "startDate":"2012-05-01"
     }
  },
  "rowCount":366,
  "rows":[
    {
      "date":"2012-05-01",
      "dfaRevenue":0.0,
      "visits last month":0.0
    },
    {
      "date":"2012-05-02",
      "dfaRevenue":0.0,
      "visits last month":0.0
    },
    {
      "date":"2012-05-03",
      "dfaRevenue":0.0,
      "visits last month":0.0
    },
    {
      "date":"2012-05-04",
      "dfaRevenue":0.0,
      "visits last month":0.0
     },
     ...
  ]
}
        

अगर पुष्टि नहीं हो पाती है

अगर रिपोर्ट की पुष्टि नहीं हो पाती है, तो Search Ads 360, एचटीटीपी 400 रिस्पॉन्स दिखाता है गड़बड़ी ऑब्जेक्ट के साथ. उदाहरण के लिए, ऊपर उदाहरण में बताए गए अनुरोध में एजेंसी:

{
 "error": {
   "code": 400,
   "message": "statisticsCurrency: the agency in scope does not have a valid currency. Please make sure the agency is properly initialized in Search Ads 360."
 }
}

सिंक्रोनस रिपोर्ट को एक से ज़्यादा जवाबों में बांटना

डिफ़ॉल्ट रूप से, सिंक्रोनस अनुरोध पहली 10,000 लाइनें दिखाता है. उस व्यवहार को बदलने के लिए, Reports.request.startRow का इस्तेमाल करें और Reports.request.rowCount प्रॉपर्टी का इस्तेमाल करके, हर अनुरोध के साथ रिपोर्ट के खास हिस्सों को वापस पाया जा सकता है.

सिंक्रोनस रिपोर्ट को बांटने का उदाहरण

उदाहरण के लिए, यह अनुरोध किसी एजेंसी रिपोर्ट की पहली सौ पंक्तियां (0 से 99) दिखाएगा जो दिन के अनुसार सेगमेंट किए जाते हैं:

{
  "reportScope": {
    "agencyId": "12300000000000456", // Replace with your ID
    "advertiserId": "21700000000011523", // Replace with your ID
    "engineAccountId": "700000000073991" // Replace with your ID
  },
  "reportType": "account",
  "columns": [
    { "columnName": "date" },
    { "columnName": "dfaRevenue" }
  ],
  "timeRange" : {
    "startDate" : "2012-05-01",
    "endDate" : "2013-05-01"
  },
  "startRow":"0",
  "rowCount":"100",
  "statisticsCurrency": "agency",
  "verifySingleTimeZone": false,
  "includeRemovedEntities": false
}
    

इस अनुरोध को फ़ॉलो करके, 100 से 199 तक की पंक्तियों के लिए एक और अनुरोध किया जा सकता है:

{
  "reportScope": {
    "agencyId": "12300000000000456", // Replace with your ID
    "advertiserId": "21700000000011523", // Replace with your ID
    "engineAccountId": "700000000073991" // Replace with your ID
  },
  "reportType": "account",
  "columns": [
    { "columnName": "date" },
    { "columnName": "dfaRevenue" }
  ],
  "timeRange" : {
    "startDate" : "2012-05-01",
    "endDate" : "2013-05-01"
  },
  "startRow":"100",
  "rowCount":"100",
  "statisticsCurrency": "agency",
  "verifySingleTimeZone": false,
  "includeRemovedEntities": false
}