يمكنك استخدام منتجات متعددة من custombatch
إلى insert
أو get
أو delete
في الوقت نفسه من خلال طلب بيانات واحد من واجهة برمجة التطبيقات.
استخدِم عنوان URL للطلب التالي لإجراء طلب بواجهات برمجة تطبيقات الدُفعات المخصَّصة:
POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch
يحتوي نص الطلب على معلَمات معيّنة: batchId
وmerchantID
وmethod
.
لا تستخدِم productId
إلا إذا كنت بصدد تنفيذ طلب الحصول أو الحذف. ولا يلزم وجود productId
عند طلب بيانات من واجهة برمجة التطبيقات في custombatch
.
custombatch:insert
يتم استخدام عنوان URL للطلب التالي لإنشاء products.custombatch method=insert
POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch
لإدراج المنتجَين الجديدَين، حدِّد السمة batchId
لكلّ منتج وسمة merchantId
الخاصة بالتاجر المعتمَد لإجراء طلب بيانات من واجهة برمجة التطبيقات والطريقة
insert
.
في المثال التالي، القيمتان batchId
هما 1111
و1112
على التوالي، وهما معرّفتان فريدتان لكلّ منتج. تشير السمة merchantId:
1234567
إلى التاجر المصرّح له بإجراء طلب بيانات من واجهة برمجة التطبيقات، والطريقة هي get
أو delete
أو insert
.
تنشئ السمة insert
منتجًا جديدًا. في حال توفّر قيم للسمات channel
وcontentLanguage
وofferId
وfeedLabel
لمنتج معيّن، ستعدِّل هذه الطريقة الإدخال وتستبدل كل البيانات من طلبات البيانات السابقة للمنتج من واجهة برمجة التطبيقات.
في ما يلي نموذج لنص JSON يتضمّن insert
قميصَين في قاعدة بيانات Merchant Center باستخدام طلب بيانات واحد من واجهة برمجة التطبيقات:
{
"entries": [
{
"batchId": 1111,
"merchantId": 1234567,
"method": "insert",
"product": {
"kind": "content#product",
"offerId": "1111111111",
"title": "Google Tee Black",
"description": "The Black Google Tee is available in unisex sizing and
features a retail fit.",
"link": "http://my.site.com/blacktee/",
"imageLink": "https://shop.example.com/.../images/GGOEGXXX1100.jpg",
"contentLanguage": "en",
"targetCountry": "US",
"feedLabel": "US",
"channel": "online",
"ageGroup": "adult",
"availability": "in stock",
"availabilityDate": "2019-01-25T13:00:00-08:00",
"brand": "Google",
"color": "black",
"condition": "new",
"gender": "male",
"googleProductCategory": "1604",
"gtin": "608802531656",
"itemGroupId": "google_tee",
"mpn": "608802531656",
"price": {
"value": "21.99",
"currency": "USD"
},
"sizes": [
"Large"
],
"includedDestination": [
"Shopping"
]
}
},
{
"batchId": 1112,
"merchantId": 1234567,
"method": "insert",
"product": {
"kind": "content#product",
"offerId": "2222222222",
"title": "Google Tee Green",
"description": "100% cotton jersey fabric sets this Google t-shirt above
the crowd. Features the google logo across the chest. Unisex sizing.",
"link": "http://my.site.com/greentee/",
"imageLink": "https://shop.example.com/.../images/GGOEGXXX0906.jpg",
"contentLanguage": "en",
"targetCountry": "US",
"feedLabel": "US",
"channel": "online",
"ageGroup": "adult",
"availability": "in stock",
"availabilityDate": "2019-01-25T13:00:00-08:00",
"brand": "Google",
"color": "green",
"condition": "new",
"gender": "male",
"googleProductCategory": "1604",
"gtin": "608802531649",
"itemGroupId": "google_tee",
"mpn": "608802531649",
"price": {
"value": "21.99",
"currency": "USD"
},
"sizes": [
"Medium"
],
"includedDestination": [
"Shopping"
]
}
}
]
}
يؤدي طلب البيانات الناجح من واجهة برمجة التطبيقات إلى عرض رمز HTTP 200
واستجابة JSON تتضمّن المنتجات التي تم إدراجها. يشبه تنسيق JSON للعرض ما يلي:
{
"kind": "content#productsCustomBatchResponse",
"entries": [
{
"kind": "content#productsCustomBatchResponseEntry",
"batchId": 1111,
"product": {
"kind": "content#product",
"id": "online:en:US:1111111111",
"offerId": "1111111111",
"title": "Google Tee Black",
"description": "The Black Google Tee is available in unisex sizing and
features a retail fit.",
"link": "http://my.site.com/blacktee/",
"imageLink": "https://shop.example.com/.../images/GGOEGXXX1100.jpg",
"contentLanguage": "en",
"targetCountry": "US",
"feedLabel": "US",
"channel": "online",
"ageGroup": "adult",
"availability": "in stock",
"availabilityDate": "2019-01-25T13:00:00-08:00",
"brand": "Google",
"color": "black",
"condition": "new",
"gender": "male",
"googleProductCategory": "1604",
"gtin": "608802531656",
"itemGroupId": "google_tee",
"mpn": "608802531656",
"price": {
"value": "21.99",
"currency": "USD"
},
"sizes": [
"Large"
],
"includedDestination": [
"Shopping"
]
}
},
{
"kind": "content#productsCustomBatchResponseEntry",
"batchId": 1112,
"product": {
"kind": "content#product",
"id": "online:en:US:2222222222",
"offerId": "2222222222",
"title": "Google Tee Green",
"description": "100% cotton jersey fabric sets this Google t-shirt above
the crowd. Features the google logo across the chest. Unisex sizing.",
"link": "http://my.site.com/greentee/",
"imageLink": "https://shop.example.com/.../images/GGOEGXXX0906.jpg",
"contentLanguage": "en",
"targetCountry": "US",
"feedLabel": "US",
"channel": "online",
"ageGroup": "adult",
"availability": "in stock",
"availabilityDate": "2019-01-25T13:00:00-08:00",
"brand": "Google",
"color": "green",
"condition": "new",
"gender": "male",
"googleProductCategory": "1604",
"gtin": "608802531649",
"itemGroupId": "google_tee",
"mpn": "608802531649",
"price": {
"value": "21.99",
"currency": "USD"
},
"sizes": [
"Medium"
],
"includedDestination": [
"Shopping"
]
}
}
]
}
custombatch:get
عنوان URL للطلب التالي يجري استدعاء products.custombatch
مع method=get
:
POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch
للحصول على منتج، حدِّد السمة batchId
الفريدة للمنتج المعني بطلب البيانات من واجهة برمجة التطبيقات، وسمة merchantId
الخاصة بالتاجر المفوّض لإجراء طلب بيانات من واجهة برمجة التطبيقات، والطريقة get
، وproductId
للمنتج الذي يتم استرداده.
في ما يلي نموذج لنص طلب JSON لاسترداد المنتجَين اللذين تم إدراجهما باستخدام مثال custombatch:insert
السابق والمحددَين في قيم productId
. تكون قيمة batchId
فريدة لكل عنصر في القائمة:
{
"entries": [
{
"batchId": 1113,
"merchantId": 1234567,
"method": "get",
"productId": "online:en:US:1111111111"
},
{
"batchId": 1114,
"merchantId": 1234567,
"method": "get",
"productId": "online:en:US:2222222222"
}
]
}
تعرض هذه الاستدعاء رمز HTTP 200
ونص الاستجابة التالي:
{
"kind": "content#productsCustomBatchResponse",
"entries": [
{
"kind": "content#productsCustomBatchResponseEntry",
"batchId": 1113,
"product": {
"kind": "content#product",
"id": "online:en:US:1111111111",
"offerId": "1111111111",
"title": "Google Tee Black",
"description": "The Black Google Tee is available in unisex sizing and features a retail fit.",
"link": "http://my.site.com/blacktee/",
"imageLink": "https://shop.example.com/.../images/GGOEGXXX1100.jpg",
"contentLanguage": "en",
"targetCountry": "US",
"feedLabel": "US",
"channel": "online",
"ageGroup": "adult",
"availability": "in stock",
"availabilityDate": "2019-01-25T13:00:00-08:00",
"brand": "Google",
"color": "black",
"condition": "new",
"gender": "male",
"googleProductCategory": "1604",
"gtin": "608802531656",
"itemGroupId": "google_tee",
"mpn": "608802531656",
"price": {
"value": "21.99",
"currency": "USD"
},
"sizes": [
"Large"
],
"includedDestination": [
"Shopping"
]
}
},
{
"kind": "content#productsCustomBatchResponseEntry",
"batchId": 1114,
"product": {
"kind": "content#product",
"id": "online:en:US:2222222222",
"offerId": "2222222222",
"title": "Google Tee Green",
"description": "100% cotton jersey fabric sets this Google t-shirt above the crowd.
Features the google logo across the chest. Unisex sizing.",
"link": "http://my.site.com/greentee/",
"imageLink": "https://shop.example.com/.../images/GGOEGXXX0906.jpg",
"contentLanguage": "en",
"targetCountry": "US",
"feedLabel": "US",
"channel": "online",
"ageGroup": "adult",
"availability": "in stock",
"availabilityDate": "2019-01-25T13:00:00-08:00",
"brand": "Google",
"color": "green",
"condition": "new",
"gender": "male",
"googleProductCategory": "1604",
"gtin": "608802531649",
"itemGroupId": "google_tee",
"mpn": "608802531649",
"price": {
"value": "21.99",
"currency": "USD"
},
"sizes": [
"Medium"
],
"includedDestination": [
"Shopping"
]
}
}
]
}
custombatch:حذف
يتم استخدام عنوان URL التالي للطلب لإنشاء products.custombatch
مع method=delete
:
POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch
لحذف منتج، حدِّد السمة batchId
الفريدة للمنتج ضمن طلب البيانات من واجهة برمجة التطبيقات هذا، وmerchantId
الخاص بالتاجر المفوّض لإجراء طلب البيانات من واجهة برمجة التطبيقات هذا، كما حدِّد الطريقة delete
وproductId
للمنتج الذي يتم حذفه.
{
"entries": [
{
"batchId": 1115,
"merchantId": 1234567,
"method": "delete",
"productId": "online:en:US:1111111111"
},
{
"batchId": 1116,
"merchantId": 1234567,
"method": "delete",
"productId": "online:en:US:2222222222"
}
]
}
تعرض هذه الاستدعاء رمز HTTP 200
وقيم batchId
للعناصر المحذوفة:
{
"kind": "content#productsCustomBatchResponse",
"entries": [
{
"kind": "content#productsCustomBatchResponseEntry",
"batchId": 1115
},
{
"kind": "content#productsCustomBatchResponseEntry",
"batchId": 1116
}
]
}