Uploads: list

Memerlukan otorisasi

Upload daftar yang dapat diakses pengguna. Coba sekarang atau lihat contohnya.

Selain parameter standar, metode ini mendukung parameter yang tercantum dalam tabel parameter.

Permintaan

Permintaan HTTP

GET https://www.googleapis.com/analytics/v3/management/accounts/accountId/webproperties/webPropertyId/customDataSources/customDataSourceId/uploads

Parameter

Nama parameter Nilai Deskripsi
Parameter jalur
accountId string ID Akun yang akan diambil upload.
customDataSourceId string ID sumber data kustom yang akan diambil oleh upload.
webPropertyId string ID properti web yang akan diambil oleh upload.
Parameter kueri opsional
max-results integer Jumlah maksimum upload yang akan disertakan dalam respons ini.
start-index integer Indeks berbasis 1 dari upload pertama yang akan diambil. Gunakan parameter ini sebagai mekanisme penomoran halaman beserta parameter hasil maksimal.

Otorisasi

Permintaan ini memerlukan otorisasi dengan setidaknya salah satu cakupan berikut (baca selengkapnya tentang autentikasi dan otorisasi).

Cakupan
https://www.googleapis.com/auth/analytics
https://www.googleapis.com/auth/analytics.edit
https://www.googleapis.com/auth/analytics.readonly

Isi permintaan

Jangan memberikan isi permintaan dengan metode ini.

Respons

Jika berhasil, metode ini akan menampilkan isi respons dengan struktur berikut:

{
  "kind": "analytics#uploads",
  "totalResults": integer,
  "startIndex": integer,
  "itemsPerPage": integer,
  "previousLink": string,
  "nextLink": string,
  "items": [
    management.uploads Resource
  ]
}
Nama properti Nilai Deskripsi Catatan
kind string Jenis koleksi.
totalResults integer Jumlah total hasil untuk kueri, terlepas dari jumlah resource dalam hasil.
startIndex integer Indeks awal resource, yaitu 1 secara default atau ditetapkan oleh parameter kueri indeks awal.
itemsPerPage integer Jumlah maksimum resource yang dapat ditampung respons, berapa pun jumlah resource sebenarnya yang ditampilkan. Nilainya berkisar dari 1 hingga 1.000 dengan nilai 1.000 secara default, atau ditentukan oleh parameter kueri hasil maksimal.
items[] list Daftar upload.

Contoh

Catatan: Contoh kode yang tersedia untuk metode ini tidak merepresentasikan semua bahasa pemrograman yang didukung (lihat halaman library klien untuk mengetahui daftar bahasa yang didukung).

Java

Menggunakan library klien Java.

/*
 * Note: This code assumes you have an authorized Analytics service object.
 * See the Data Import Developer Guide for details.
 */

/*
 * Example #1:
 * Requests a list of all uploads for the authorized user.
 */
try {
  Uploads uploads = analytics.management().uploads().list("123456",
      "UA-123456-1", "122333444455555").execute();
} catch (GoogleJsonResponseException e) {
  System.err.println("There was a service error: "
      + e.getDetails().getCode() + " : "
      + e.getDetails().getMessage());
}

/*
 * Example #2:
 * The results of the list method are stored in the uploads object.
 * The following code shows how to iterate through them.
 */
for (Upload upload : uploads.getItems()) {
  System.out.println("Uploads Id            = " + upload.getId());
  System.out.println("Upload Kind           = " + upload.getKind());
  System.out.println("Account Id            = " + upload.getAccountId());
  System.out.println("Custom Data Source Id = " + upload.getCustomDataSourceId());
  System.out.println("Upload Status         = " + upload.getStatus() + "\n");
}

PHP

Menggunakan library klien PHP.

/**
 * Note: This code assumes you have an authorized Analytics service object.
 * See the Data Import Developer Guide for details.
 */

/**
 * Example #1:
 * Requests a list of all uploads for the authorized user.
 */
try {
  $uploads = $analytics->management_uploads->listManagementuploads('123456',
      'UA-123456-1', '122333444455555');

} catch (apiServiceException $e) {
  print 'There was an Analytics API service error '
      . $e->getCode() . ':' . $e->getMessage();

} catch (apiException $e) {
  print 'There was a general API error '
      . $e->getCode() . ':' . $e->getMessage();
}


/**
 * Example #2:
 * The results of the list method are stored in the uploads object.
 * The following code shows how to iterate through them.
 */
foreach ($uploads->getItems() as $upload) {

  $html = <<<HTML
<pre>
Upload id     = {$upload->getId()}
Upload kind   = {$upload->getKind()}
Account id    = {$upload->getAccountId()}
Data set id   = {$upload->getCustomDataSourceId()}
Upload status = {$upload->getStatus()}
</pre>

HTML;
  print $html;
}



Python

Menggunakan library klien Python.

# Note: This code assumes you have an authorized Analytics service object.
# See the Uploads Dev Guide for details.

# Example #1:
# Requests a list of all uploads for the authorized user.
try:
  uploads = analytics.management().uploads().list(
      accountId='123456',
      webPropertyId='UA-123456-1',
      customDataSourceId='ABCDEFG123abcDEF123'
  ).execute()

except TypeError, error:
  # Handle errors in constructing a query.
  print 'There was an error in constructing your query : %s' % error

except HttpError, error:
  # Handle API errors.
  print ('There was an API error : %s : %s' %
         (error.resp.status, error.resp.reason))


# Example #2:
# The results of the list method are stored in the uploads object.
# The following code shows how to iterate through them.
for upload in uploads.get('items', []):
  print 'Upload Id             = %s' % upload.get('id')
  print 'Upload Kind           = %s' % upload.get('kind')
  print 'Account Id            = %s' % upload.get('accountId')
  print 'Custom Data Source Id = %s' % upload.get('customDataSourceId')
  print 'Upload Status         = %s\n' % upload.get('status')



JavaScript

Menggunakan library klien JavaScript.

/*
 * Note: This code assumes you have an authorized Analytics client object.
 * See the Data Import Developer Guide for details.
 */

/*
 * Example 1:
 * Requests a list of all Uploads for the authorized user.
 */
function listUploads() {
  var request = gapi.client.analytics.management.uploads.list({
    'accountId': '123456',
    'webPropertyId': 'UA-123456-1',
    'customDataSourceId': 'ABCDEFG123abcDEF123',
  });
  request.execute(printUploads);
}

/*
 * Example 2:
 * The results of the list method are passed as the results object.
 * The following code shows how to iterate through them.
 */
function printUploads(results) {
  if (results && !results.error) {
    var uploads = results.items;
    for (var i = 0, upload; upload = uploads[i]; i++) {
      console.log('Upload Id: ' + upload.id);
      console.log('Upload Kind: ' + upload.kind);
      console.log('Account Id: ' + upload.accountId);
      console.log('Data Set Id: ' + upload.customDataSourceId);
      console.log('Upload Status: ' + upload.status);
    }
  }
}

Cobalah!

Gunakan APIs Explorer di bawah untuk memanggil metode ini pada data live dan melihat responsnya. Atau, coba Explorer mandiri.