इसके लिए, अनुमति देना ज़रूरी है
टाइमलाइन आइटम को अपडेट किया जाता है. उदाहरण देखें.
यह तरीका /upload यूआरआई के साथ काम करता है और नीचे दी गई विशेषताओं के आधार पर अपलोड किया गया मीडिया स्वीकार करता है:
- फ़ाइल इससे बड़ी नहीं होनी चाहिए: 10 एमबी
- स्वीकार किए जाने वाले मीडिया MIME टाइप:
audio/*
,image/*
,video/*
अनुरोध करें
एचटीटीपी अनुरोध
इस तरीके से, दो अलग-अलग यूआरआई के ज़रिए मीडिया अपलोड करने की सुविधा मिलती है. ज़्यादा जानकारी के लिए, मीडिया अपलोड पर दस्तावेज़ देखें.
- मीडिया अपलोड अनुरोधों के लिए यूआरआई अपलोड करें:
PUT https://www.googleapis.com/upload/mirror/v1/timeline/id
- सिर्फ़ मेटाडेटा के अनुरोधों के लिए मेटाडेटा यूआरआई:
PUT https://www.googleapis.com/mirror/v1/timeline/id
पैरामीटर
पैरामीटर का नाम | वैल्यू | जानकारी |
---|---|---|
पाथ पैरामीटर | ||
id |
string |
टाइमलाइन आइटम का आईडी. |
क्वेरी के ज़रूरी पैरामीटर | ||
uploadType |
string |
/upload यूआरआई पर अपलोड का अनुरोध.
ये वैल्यू डाली जा सकती हैं:
|
अनुमति देना
इस अनुरोध के लिए, इनमें से कम से कम एक दायरे की अनुमति लेना ज़रूरी है. पुष्टि करने और अनुमति देने के बारे में ज़्यादा जानें.
स्कोप |
---|
https://www.googleapis.com/auth/glass.timeline |
https://www.googleapis.com/auth/glass.location |
अनुरोध का मुख्य भाग
अनुरोध के मुख्य हिस्से में, मेटाडेटा के तौर पर इन प्रॉपर्टी के साथ टाइमलाइन संसाधन दें. ज़्यादा जानकारी के लिए, मीडिया अपलोड पर दस्तावेज़ देखें.
प्रॉपर्टी का नाम | वैल्यू | ब्यौरा | ज़रूरी जानकारी |
---|---|---|---|
ज़रूरी प्रॉपर्टी नहीं | |||
bundleId |
string |
इस आइटम का बंडल आईडी. कई आइटम को एक साथ ग्रुप करने के लिए सेवाएं, एक बंडल आईडी बता सकती हैं. ये आइटम, डिवाइस में किसी टॉप लेवल आइटम के नीचे दिखते हैं. | लिखा जा सकता है |
canonicalUrl |
string |
टाइमलाइन आइटम के ज़रिए दिखाए गए डेटा के कैननिकल/अच्छी क्वालिटी वाले वर्शन पर ले जाने वाला कैननिकल यूआरएल. | लिखा जा सकता है |
creator |
nested object |
वह उपयोगकर्ता या ग्रुप जिसने यह आइटम बनाया है. | लिखा जा सकता है |
displayTime |
datetime |
इस आइटम को टाइमलाइन में देखने का समय, आरएफ़सी 3339 के मुताबिक फ़ॉर्मैट किया जाना चाहिए. इस उपयोगकर्ता की टाइमलाइन, समय के हिसाब से, डिसप्ले समय पर क्रम से लगाई जाती है. इससे यह भी तय होता है कि टाइमलाइन में आइटम कहां दिखाया जाएगा. अगर सेवा ने इसे सेट नहीं किया है, तो डिसप्ले टाइम डिफ़ॉल्ट रूप से updated समय होता है. |
लिखा जा सकता है |
html |
string |
इस आइटम का एचटीएमएल कॉन्टेंट. अगर किसी आइटम के लिए text और html , दोनों दिए गए हैं, तो html को टाइमलाइन में रेंडर किया जाएगा. मंज़ूर किए गए एचटीएमएल एलिमेंट - आप अपने टाइमलाइन कार्ड में इन एलिमेंट का इस्तेमाल कर सकते हैं.
ब्लॉक किए गए एचटीएमएल एलिमेंट: ये एलिमेंट और उनके कॉन्टेंट, एचटीएमएल पेलोड से हटा दिए जाते हैं.
अन्य एलिमेंट: जो एलिमेंट सूची में नहीं हैं उन्हें हटा दिया जाता है, लेकिन उनका कॉन्टेंट सुरक्षित रखा जाता है. |
लिखा जा सकता है |
isBundleCover |
boolean |
यह आइटम, बंडल कवर है या नहीं. अगर किसी आइटम को बंडल कवर के रूप में मार्क किया जाता है, तो वह उस आइटम के बंडल के लिए एंट्री पॉइंट होगा जो bundleId उस आइटम के समान है. यह सिर्फ़ मुख्य समयावधि पर दिखाया जाएगा — खुले बंडल में नहीं.मुख्य समयावधि के दौरान, ये आइटम दिखाए जाते हैं:
|
लिखा जा सकता है |
location |
nested object |
इस आइटम से जुड़ी भौगोलिक जगह. | लिखा जा सकता है |
menuItems[] |
list |
ऐसे मेन्यू आइटम की सूची जिन्हें टाइमलाइन में चुने जाने के बाद, लोगों को दिखाया जाएगा. | लिखा जा सकता है |
menuItems[].action |
string |
उस समय के व्यवहार को कंट्रोल करता है, जब उपयोगकर्ता मेन्यू का विकल्प चुनता है. ये वैल्यू इस्तेमाल की जा सकती हैं:
|
लिखा जा सकता है |
menuItems[].id |
string |
इस मेन्यू आइटम का आईडी. यह ऐप्लिकेशन से जनरेट होता है और इसे अपारदर्शी टोकन माना जाता है. | लिखा जा सकता है |
menuItems[].payload |
string |
एक सामान्य पेलोड, जिसका मतलब इस MenuItem की कार्रवाई के आधार पर बदलता है.
|
लिखा जा सकता है |
menuItems[].removeWhenSelected |
boolean |
अगर इसे CUSTOM मेन्यू आइटम पर 'सही है' पर सेट किया जाता है, तो उस आइटम को चुनने के बाद, उसे मेन्यू से हटा दिया जाएगा. |
लिखा जा सकता है |
menuItems[].values[] |
list |
CUSTOM आइटम के लिए, इसकी सूची के अलग-अलग राज्यों में मेन्यू आइटम के लुक को कंट्रोल किया जाता है. DEFAULT स्थिति के लिए एक वैल्यू दी जानी चाहिए. अगर PENDING या CONFIRMED राज्य मौजूद नहीं हैं, तो वे नहीं दिखाए जाएंगे. |
लिखा जा सकता है |
menuItems[].values[].displayName |
string |
मेन्यू आइटम के लिए दिखने वाला नाम. अगर आप पहले से मौजूद मेन्यू आइटम के लिए इस प्रॉपर्टी को तय करते हैं, तो उस आइटम के लिए, निर्देश के तौर पर डिफ़ॉल्ट वॉइस कमांड नहीं दिखाया जाएगा. | लिखा जा सकता है |
menuItems[].values[].iconUrl |
string |
मेन्यू आइटम के साथ दिखाने के लिए, आइकॉन का यूआरएल. | लिखा जा सकता है |
menuItems[].values[].state |
string |
वह राज्य जिस पर यह वैल्यू लागू होती है. ये वैल्यू इस्तेमाल की जा सकती हैं:
|
लिखा जा सकता है |
notification |
nested object |
इस नीति से यह कंट्रोल किया जाता है कि डिवाइस में इस आइटम की सूचनाएं किस तरह दिखाई जाएं. अगर यह जानकारी मौजूद नहीं है, तो कोई सूचना जनरेट नहीं की जाएगी. | लिखा जा सकता है |
notification.deliveryTime |
datetime |
सूचना डिलीवर होने का समय. | लिखा जा सकता है |
notification.level |
string |
यह बताता है कि सूचना कितनी ज़रूरी है. ये वैल्यू डाली जा सकती हैं:
|
लिखा जा सकता है |
recipients[] |
list |
उन लोगों या ग्रुप की सूची जिनके साथ यह आइटम शेयर किया गया है. | लिखा जा सकता है |
sourceItemId |
string |
एक अपारदर्शिता स्ट्रिंग, जिसे आप अपनी सेवा में डेटा के लिए एक टाइमलाइन आइटम को मैप करने के लिए इस्तेमाल कर सकते हैं. | लिखा जा सकता है |
speakableText |
string |
इस आइटम के कॉन्टेंट का बोलकर बताने वाला वर्शन. READ_ALOUD के मेन्यू आइटम के साथ, इस फ़ील्ड का इस्तेमाल, टेक्स्ट को इस तरह से करने के लिए करें कि उसे ज़ोर से पढ़कर सुनाया जा सके. इसके अलावा, उसका इस्तेमाल ग्लास पर दिखने वाले कॉन्टेंट के बारे में ज़्यादा जानकारी देने के लिए भी किया जा सकता है.Glassware को speakableटाइप फ़ील्ड भी बताना चाहिए, जो इस टेक्स्ट से पहले बोला जाएगा. ऐसा तब किया जाता है, जब ज़्यादा संदर्भ काम का होता है. उदाहरण के लिए, जब उपयोगकर्ता किसी सूचना के बाद आइटम को पढ़ने का अनुरोध करता है. |
लिखा जा सकता है |
speakableType |
string |
इस आइटम के प्रकार का विवरण देने वाला ब्यौरा. जिन मामलों में ज़्यादा जानकारी ज़रूरी हो उन मामलों में, आइटम की सामग्री पढ़ने से पहले उपयोगकर्ता को इसकी सूचना दी जाएगी. उदाहरण के लिए, जब उपयोगकर्ता सूचना पाने के बाद उसे पढ़ने का अनुरोध करता है. में "ईमेल", "मैसेज" या "रोज़ के ग्रह की खबरों का अपडेट" जैसे छोटे, आसान संज्ञा वाले वाक्यांश होने चाहिए. Glassware को यह टाइमलाइन आइटम के लिए इस फ़ील्ड को पॉप्युलेट करने के लिए प्रोत्साहित किया जाता है. भले ही, आइटम में speakable टेक्स्ट या टेक्स्ट न हो, ताकि उपयोगकर्ता स्क्रीन को देखे बिना ही आइटम का टाइप जान सके. |
लिखा जा सकता है |
text |
string |
इस आइटम का टेक्स्ट कॉन्टेंट. | लिखा जा सकता है |
title |
string |
इस आइटम का शीर्षक. | लिखा जा सकता है |
जवाब
अगर यह तरीका काम करता है, तो रिस्पॉन्स के मुख्य भाग में टाइमलाइन का रिसॉर्स दिखता है.
उदाहरण
ध्यान दें: इस तरीके के लिए दिए गए कोड के उदाहरणों में इसके साथ काम करने वाली सभी प्रोग्रामिंग भाषाएं नहीं दिखाई गई हैं (इसके साथ काम करने वाली भाषाओं की सूची के लिए क्लाइंट लाइब्रेरी वाला पेज देखें).
Java
Java क्लाइंट लाइब्रेरी का इस्तेमाल करता है.
import com.google.api.services.mirror.Mirror; import com.google.api.services.mirror.model.NotificationConfig; import com.google.api.services.mirror.model.TimelineItem; import java.io.IOException; public class MyClass { // ... /** * Update a timeline item in the user's Glass with an optional notification and attachment. * * @param service Authorized Mirror service. * @param itemId ID of the timeline item to update. * @param newText timeline item's text. * @param newNotificationLevel Optional notification level, supported values * are {@code null} and "AUDIO_ONLY". * @return Updated timeline item on success, {@code null} otherwise. */ public static TimelineItem updateTimelineItem(Mirror service, String itemId, String newText, String newNotificationLevel) { try { // First retrieve the timeline item from the API. TimelineItem timelineItem = service.timeline().get(itemId).execute(); // Update the timeline item's metadata. timelineItem.setText(newText); if (newNotificationLevel != null && newNotificationLevel.length() > 0) { timelineItem.setNotification(new NotificationConfig().setLevel(newNotificationLevel)); } else { timelineItem.setNotification(null); } return service.timeline().update(itemId, timelineItem).execute(); } catch (IOException e) { System.err.println("An error occurred: " + e); return null; } } // ... }
.NET
.NET क्लाइंट लाइब्रेरी का इस्तेमाल करता है.
using System; using System.IO; using Google.Apis.Mirror.v1; using Google.Apis.Mirror.v1.Data; public class MyClass { // ... /// <summary> /// Update a timeline item in the user's Glass with an optional /// notification and attachment. /// </summary> /// <param name='service'>Authorized Mirror service.</param> /// <param name='itemId'>ID of the timeline item to update.</param> /// <param name='newText'>Timeline Item's text content.</param> /// <param name='newNotificationLevel'> /// Optional notification level, supported values are null and /// "AUDIO_ONLY". /// </param> /// <returns> /// Updated timeline item on success, null otherwise. /// </returns> public static TimelineItem UpdateTimelineItem(MirrorService service, String itemId, String newText, String newNotificationLevel) { try { // First retrieve the timeline item from the API. TimelineItem timelineItem = service.Timeline.Get(itemId).Fetch(); // Update the timeline item's metadata. timelineItem.Text = newText; if (!String.IsNullOrEmpty(newNotificationLevel)) { timelineItem.Notification = new NotificationConfig() { Level = newNotificationLevel }; } else { timelineItem.Notification = null; } return service.Timeline.Update(timelineItem, itemId).Fetch(); } catch (Exception e) { Console.WriteLine("An error occurred: " + e.Message); return null; } } // ... }
PHP
PHP क्लाइंट लाइब्रेरी का इस्तेमाल करता है.
/** * Update a timeline item in the user's Glass with an optional * notification and attachment. * * @param Google_MirrorSservice $service Authorized Mirror service. * @param string $itemId ID of the timeline item to update. * @param string $newText timeline item's text (can be HTML content). * @param string $newNotificationLevel Optional notification level, * supported values are {@code null} and "AUDIO_ONLY". * @return Google_TimelineItem Updated timeline item on success, * null otherwise. */ function updateTimelineItem($service, $itemId, $newText, $newNotificationLevel) { try { $timelineItem = $service->timeline->get($itemId); $timelineItem->setText($newText); if ($notificationlevel != null) { $notification = new Google_NotificationConfig(); $notification->setLevel($newNotificationLevel); $timelineItem->setNotification($notification); } else { $timelineItem->setNotification(null); } return $service->timeline->update($itemId, $timelineItem); } catch (Exception $e) { print 'An error occurred: ' . $e->getMessage(); return null; } }
Python
Python क्लाइंट लाइब्रेरी का इस्तेमाल करता है.
import io from apiclient import errors from apiclient.http import MediaIoBaseUpload # ... def update_timeline_item(service, item_id, new_text, new_notification_level=None): """Update a timeline item in the user's Glass. Args: service: Authorized Mirror service. item_id: ID of the timeline item to update. new_text: Timeline item's text (can be HTML content). new_content_type: Optional attachment's content type (supported content types are 'image/*', 'video/*' and 'audio/*'). new_attachment: Optional attachment as data string. new_notification_level: Optional notification level, supported values are None and 'AUDIO_ONLY'. Returns: Updated timeline item on success, None otherwise. """ try: # First retrieve the timeline item from the API. timeline_item = service.timeline().get(id=item_id).execute() # Update the timeline item's metadata. timeline_item['text'] = new_text if new_notification_level: timeline_item['notification'] = {'level': new_notification_level} elif 'notification' in timeline_item: timeline_item.pop('notification') return service.timeline().update(id=item_id, body=timeline_item).execute() except errors.HttpError, error: print 'An error occurred: %s' % error return None
Ruby
Ruby क्लाइंट लाइब्रेरी का इस्तेमाल करता है.
## # Update a timeline item in the user's glass. # # @param [Google::APIClient] client # Authorized client instance. # @param [String] item_id # ID of the timeline item to update. # @param [String] new_text # Timeline item's new text. # @param [String] new_notification_level # Optional new notification level, supported values are nil and 'AUDIO_ONLY'. # @return [Google::APIClient::Schema::Mirror::V1::TimelineItem] # Updated timeline item instance if successful, nil otherwise. def update_timeline_item(client, item_id, new_text, new_notification_level) mirror = client.discovered_api('mirror', 'v1') result = client.execute( :api_method => mirror.timeline.get, :parameters => { 'id' => item_id }) if result.success? timeline_item = result.data timeline_item.text = new_text if new_notification_level timeline_item.notification = { 'level' => new_notification_level } else timeline_item.notification = nil end result = client.execute( :api_method => mirror.timeline.update, :body_object => timeline_item, :parameters => { 'id' => item_id }) if result.success? return result.data end end puts "An error occurred: #{result.data['error']['message']}" end
शुरू करें
Go क्लाइंट लाइब्रेरी का इस्तेमाल करता है.
import ( "code.google.com/p/google-api-go-client/mirror/v1" "fmt" ) // UpdateTimelineItem updates a timeline item in the user's timeline with an // optional notification and attachment. func UpdateTimelineItem(g *mirror.Service, itemId string, newNotificationLevel string) ( *mirror.TimelineItem, error) { t, err := g.Timeline.Get(itemId).Do() if err != nil { fmt.Printf("An error occurred: %v\n", err) return nil, err } t.Text = newText if newNotificationLevel != "" { t.Notification = &mirror.NotificationConfig{Level: newNotificationLevel} } else { t.Notification = nil } r, err := g.Timeline.Update(itemId, t).Do() if err != nil { fmt.Printf("An error occurred: %v\n", err) return nil, err } return r, nil }
रॉ एचटीटीपी
क्लाइंट लाइब्रेरी का इस्तेमाल नहीं करता.
PUT /mirror/v1/timeline/timeline item id HTTP/1.1 Host: www.googleapis.com Authorization: Bearer auth token Content-Type: application/json Content-Length: 26 { "text": "Hello world" }