I created a simple Web Tile for Microsoft Band 2 using https://developer.microsoftband.com/WebTile. The tile installed without trouble and initially showed correct values, but it never updated. I added a notification to see if anything was happening, and the notification does get fired when the phone refreshes content, but the data is never updated even though the data changes in the feed.
Slightly sanitized feed:
<rss xmlns:a10="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>Title</title>
<link>http://website.com/band</link>
<description>Band Tile</description>
<language>en-US</language>
<copyright>2015 Company</copyright>
<lastBuildDate>Sun, 01 Nov 2015 19:25:21 Z</lastBuildDate>
<item>
<link>http://company.com/band/635820027213013187</link>
<title>635820027212075628</title>
<description>2</description>
</item>
</channel>
</rss>
The only data I'm trying to update on the Tile is the <description> value.
The <link> and <title> didn't change at first, but I added the datetime (in ticks) in hopes of convincing the app to act on the change, but no luck.
I'm using an Android phone for the Microsoft Health App.
If the web server provides an ETag value in its HTTP response, then the web tile will provide that value in its next HTTP request "If-None-Match" header to avoid downloading the same content again. Does the HTTP server you are using support ETags and if so is the value being changed on the server each time the feed content changes?
Simnilarly, the "Last-Modified" response header will be used (if provided by the server) in the next request to set the "If-Modified-Since" header. So, if the server supports this header then it is important that the Last-Modified date be set each time the feed content changes.
If the Web Tile is a feed tile (i.e. a page is shown on the Band for each new item of the feed) then additionally items of the feed will be checked to see if they match a previously seen item. For an RSS feed, the match uses the values tagged by "guid" or "pubDate" if available, otherwise a hash of the entire item.
Since your feed example does not have "guid" or "pubDate" tags for the item, the all item hash should apply. Thus the change in the value of the description to something that does not match one of the previous 8 item descriptions should cause it to be seen as new.
If you have created a feed tile using your feed data, and the first time the feed contains an item with a description of "1" then a page should be created on a Band showing that "1". Then on the next update when the feed contains an item with a description of "2" then the Band should get a new page showing that "2".
If you have created a non-feed tile (e.g. a tile with only a single page) then the page(s) on the Band should reflect the web data from the most recent sync (so long as the ETag and Last-Modified are set correctly if they are supported by the server).
For background updating, the "refreshIntervalMinutes" specified in the manifest must also elapse from the last update before a new attempt to update is made. However, if you force a sync using that option within the MS Health app then the "refreshIntervalMinutes" will be ignored.
Related
I have a plugin that puts custom post types onto a map. It uses Leaflet and specifies a REST API link as the source of its data. A map is displayed with a number of location markers and when clicked a details box pops up with the name of what's at that location and there's a hyperlink in this details box which when clicked takes the user to another page on the site. Here's what is specified as the data-endpoint source:
http://rd-dev.local/wp-json/citadela-directory/map-data/points/citadela-item?dataType=markers&category=&location=&only_featured=0
This call returns JSON that looks like this:
{"total":40,"points":[{"track":[],"coordinates":{"longitude":14.726660728455,"latitude":46.813816070557003},"title":"Name of place","permalink":"http:\/\/rd-dev.local\/item\/something\/","address":"Address, line 2, Someplace, Some Country","image":"http:\/\/rd-dev.local\/wp-content\/uploads\/2020\/12\/0b-1-150x150.jpeg","postType":"citadela-item","faIcon":"fas fa-circle","color":"#0085ba"}, ... etc
Part of each record in the response is a link to a url on the site, which the user clicks to see the detail:
http:\/\/rd-dev.local\/item\/something
I want to change the page that users see when they click a location so it occurred to me that one way, and which at my level of knowledge is probably the simplest, is to alter the JSON response that Wordpress gives. Specifically, i want to change all occurrences of "item" to a something different.
Is there a way to change the JSON stream as it is sent out by the REST API?
I solved this. I searched for register_rest_route occurrences in the source files and was able to find one for this particular route. The register_rest_route call includes a callback function where the response is constructed. It was then a case of putting that response through text replacement calls.
I'm a newbie but I think Paw can do what i need :
I need to extract a session id behind a login page.
I go to https://admin.booking.com, filling the form (login and pass) and the landing page behind includes a session id :
https://admin.booking.com/pc/index.html?ses=xxxxyyyyyzzzzz11112222233333
I'd like to :
1) Push credentials with Paw as part of my request,
2) get the above item (ses) item as a response so i can use the php script extension provided by Paw and then call this script "on demand".
Is this possible ? If so, what should i do ?
Thanks for your help
UPDATE*: we've added a documentation article to describe the process a little more: Login via a web form in Paw. We've detailed the process to deal with CSRF tokens too.
Paw isn't quite yet ready for handling web/HTML forms. Though, there's one way to do it the right way: if you inspect the form with the Chrome dev tools you'll find the name of the input from the DOM/HTML:
In your case, you have the inputs: loginname, password, lang.
Also, find the <form…> tag to see what's the action attribute. If there's no action attribute (like in your example), it means the target URL for your form is the current page's URL (https://admin.booking.com/ in your case). Also, make sure the method="POST" is also there in the <form…> tag, otherwise this method won't work.
Then jump into Paw and set:
URL (in your case https://admin.booking.com/)
method to POST
go to the Body tab and use "Form URL-Encoded + fill up the fields from your form
If all works, you'll see Paw show a redirection request, and if you go to the right-hand side panel under "Response" > "Headers", you should see a Location header with a value similar to the URL you initially mentioned (https://admin.booking.com/pc/index.html?ses=xxxxyyyyyzzzzz11112222233333). Hurray! You got your value into Paw!
Now that you have that, you can create in a new request (click on the + button at the bottom of the left-hand side list). And wherever you want to use this session token/ID, you can insert a dynamic value to retrieve that URL value. You have more infos here, in our docs, but I'll describe the steps here:
On whichever field you want to insert the token, right-click and pick Responses > Response Header.
Make sure you pick the first request in the "Request" dropdown menu, and enter Location in the "Header" field:
You should see the value of the Location header of the previous response appear here.
Now what you want to do is to extract only the part you want (i.e. the value of the ses param in your case). For that you'll need that extension for Paw, so please install it now: https://luckymarmot.com/paw/extensions/RegExMatch
Copy the dynamic value you have just inserted (the blue token), and right-click on that field to insert a new dynamic value, and pick Extensions > RegExp match:
In the Input field, paste the previous dynamic value you copied. And use the RegExp field to write a regular expression that will successfully extract the part of the URL you want (this should work in your case ses=(.*)).
Now that you're set up. You should be able to use this little new blue token wherever you like and automagically extract the value from the previous form. And whenever you send again the initial request, and get a new token, everything else will also update! :)
It was a little long guide, but I hope this will help you and hopefully others too.
Google Reader api mark all news from a specific source as read! I've sniffed the request but I can't understant which paramters it want's
This is the post
http://www.google.com/reader/api/0/mark-all-as-read?client=scroll
and all arguments are
s=user%2F1400000000005773457%2Flabel%2FCultura&t=Cultura&ts=1302000000000000772&T=%2F%2FRcaqdpNe_mDnkehf-L5af9w
NOTE: The Numeber like 14000000000057734... are not true...I masquerade it because I think they are sensible data.
My questions is can someone show me the correct request? Which are the correct parameters to do this post request?
The request that I show in this post works because I grab It from the Google Reader site.
The relevant parameters are:
s: The stream you wish to mark all as read. The example you have is marking as read the user's "Cultura" label. To mark a feed you you use feed/<feed url>
ts: The timestamp (in microseconds) you wish to mark all as items as read to. This can be the current time (to mark all items), or a date in the past (e.g. to mark all items older than 1 week as read, use the current time minus 1 weeek.
T: The action token (necessary for all POST requests)
I've encountered the same problem as described in this post:
Google Calendar api v3 re-update issue
Namely, once I create an event and update it once using the Google Calendar API (v3), I am no longer able to update the event. When I attempt to, I get a 400 - Invalid value response. (FWIW I'm working in PHP).
Following a lead offered in the post I referenced above, I attempted to solve the issue using etags (though admittedly my grasp of how they work is limited). Basically, on event update, the API returns an etag in its response, which I now save in my database. Then for subsequent (n > 1) updates, I pull the current etag from the database and include it in the http header:
Content-Type: application/json
Authorization: OAuth [token]
If-Match: [etag]
This follows info under the "Updating Entries" header here: http://code.google.com/apis/gdata/docs/2.0/reference.html#ResourceVersioning
Sidenote: in the google ref above, the If-Match header is shown as
If-Match: "S0wCTlpIIip7ImA0X0QI"
with double quotes around the etag. I'm saving the etags in the database with double quotes, exactly as I receive them in first update response. Do I need to escape the quotes or anything when adding to the header using curl_setopt/HTTPHEADER?
Despite implementing this etag If-Match thing, I'm still getting the same 400 - Invalid value response. I know that my request bodies are valid because the first update works fine. There's just some additional issue surrounding subsequent updates.
Any help much appreciated.
Make sure to increment the sequence number field when updating events.
I had same problem. To increment the sequence number you need to keep track of how many updates you have done and include the next increment in your update. For some reason the first update doesn't require this but subsequent updates do require it.
Using the google php library on your 2nd update to the event would look something like this (minus whatever else your are updating):
$calendarID = ID_OF_YOUR_CALENDAR;
$eventID = ID_OF_YOUR_EVENT;
$event = new Google_Event();
$event->setSequence('2');
$calEvent = $cal->events->update($calendarID $eventID, $event);
That is how I do it. Fetch the entry from Google so it already has the latest Etag set and increment the sequence by one and update the entry.
As I use java so following is a example with java:
com.google.api.services.calendar.model.Event googleCalendarEvent = service.events().get(clientCalendarEvent.getCalendar().getCalendarKey(),clientCalendarEvent.getEventKey()).execute();
updateGoogleCalendarEvent(clientCalendarEvent, googleCalendarEvent);
googleCalendarEvent.setSequence(googleCalendarEvent.getSequence() + 1);
com.google.api.services.calendar.model.Event event = service
.events()
.update(clientCalendarEvent.getCalendar().getCalendarKey(), clientCalendarEvent.getEventKey(),
googleCalendarEvent).execute();
I'm having trouble with jqGrid not showing the "No records to view" message when there are no records to view. I've used jqGrid pretty extensively in my application, with variable row count selection, pagination, and filtering. When the tables are initially loaded, they correctly show the number of pages, and the "View 1-10 of 50" type rowcount message. If filters are then applied to the table, the data in the table is updated correctly (using a JSON data source generated by PHP), and the page and row count messages are updated correctly.
The only problem comes when filters are applied which return no rows at all - when this happens, the page count and row count messages remain set to their previous values.
I've checked the JSON I'm returning for an empty data set, and it matches the JSON from the jqGrid demo site when there is no data:
{"page":0,"total":0,"records":"0"}
I've posted a sample at http://www.analyticsseo.com/test. Any idea what I'm doing wrong?
I don't recommend you now so old version of jqGrid like 3.8. You main problem with server response
{"page":0,"total":0,"records":"0"}
can be fixed if the server would produce
{"page":0,"total":0,"records":"0","rows":[]}
instead. The bug like many other bugs are fixed in jqGrid now. There are many new features and performance improvements.
By the way your server part use wrong Content-Type header in the response with the JSON data. The correct Content-Type is application/json, but your server uses currently text/html; charset=utf-8 instead. You can use in Drupal 6, common.inc the statement drupal_set_header('Content-Type: application/json'); to fix the problem. After such change you will be able to use more recent version of jQuery.
In the answer you find references to the link which describes how you can upgrade jQuery to new version.