Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update the image on my Glassware contact?

Is there a way to force the refresh of an image that is cached for a contact card? I changed the image that is hosted on the webservice but the contact card on Glass is not updating. It has been multiple days and multiple hardware power cycles so I am wondering if there is a command that I'm missing.

like image 748
Daniel Kaplan Avatar asked Nov 03 '22 19:11

Daniel Kaplan


1 Answers

I assume you mean the contact for your glassware, I was able to update that image and see that change reflected in Glass in seconds.

I got help from the general glass documentation and the reference documentation for Contacts on Glass.

Both are helpful but full of traps, like the former has a JSON example that isn't even valid JSON (missing commas to separate items) uses the wrong variable name for the image and is missing the kind parameter.

Here is a good example I used to test this for you:

curl -X POST -H "Authorization: Bearer ya29.YOUR_TOKEN" -H 
"Content-Type: application/json" 
--data @json-contact1.txt https://www.googleapis.com/mirror/v1/contacts

Where the txt file looks like this:

{
  "kind": "mirror#timelineItem",
  "id": "harold",
  "displayName": "Harold Penguin",
  "imageUrls": [ "http://images3.wikia.nocookie.net/__cb20110713145426/penguindrum/images/6/66/Real_penguins.png" ],
  "priority": 7
}

The raw http of this command looks like this:

POST /mirror/v1/contacts HTTP/1.1
User-Agent: curl/7.21.1 (i686-pc-mingw32) libcurl/7.21.1 OpenSSL/0.9.8r zlib/1.2.3
Host: www.googleapis.com
Accept: */*
Authorization: Bearer ya29.AHES6ZSgwltGsN16ZTP1JkklDXhDzazoZWRZmaCBltqAK6DTcSqPhw
Content-Type: application/json
Content-Length: 194

{
    "kind": "mirror#timelineItem",
    "id": "harold",
    "displayName": "Harold Penguin",
    "imageUrls": [  "http://images3.wikia.nocookie.net/__cb20110713145426/penguindrum/images/6/66/Real_penguins.png"
    ],
    "priority": 7
}

To confirm this worked I posted the contact and went into my Glass timeline, selected a photo, and selected Share, and then scrolled through the contacts until I saw Harold Penguin, it had the background photo from the Curl command. Then I modified the txt file with a new image url, resent the the Curl command, got another 200 response, and repeated the photo / share process in Glass, and this time the background for Harold Penguin was the new picture. During this entire time my Glass was connected to Wifi.

Without seeing your code its hard to diagnose your exact issue, but hopefully knowing that this works and having access to a working example you can test will help you figure that out. Although my Glassware is written in Java I like the simplicity of Curl to diagnose issues like this, it works for me, maybe it will for you.

Interesting question, thanks for it.

like image 152
Mark Scheel Avatar answered Dec 11 '22 10:12

Mark Scheel