With this. I want to use rel="next" instead of incrementing the parameter page manually
This's my Service.java Interface (using retrofit2):
#GET("user/repos")
Call<Repos> getRepos(#Query("api_key") String apiKey,
#Query("page") int pageIndex);
How can I do it? Android - using Java
By principle, HTTP RESTful APIs are stateless.
This means the Github API doesn't know what your current page is, and what your next page is.
Therefore, you must pass the page and per_page parameter.
rel="next" in the Link header indicates that the resource request is for the next page, but it can't and shouldn't be used to get the next page results without passing the page parameter.
In the simplest case, a link relation type identifies the semantics
of a link. For example, a link with the relation type "copyright"
indicates that the resource identified by the target IRI is a
statement of the copyright terms applying to the current context IRI.
Link relation types can also be used to indicate that the target
resource has particular attributes, or exhibits particular
behaviours; for example, a "service" link implies that the identified
resource is part of a defined protocol (in this case, a service
description).
From RFC-5988 Web Linking
Related
I would like to add a "Guided breathing" activity type, supported by the REST Api under id 122:
https://developers.google.com/fit/rest/v1/reference/activity-types
However, it is not available in the FitnessActivites class, despite the fact that most (all?) other are:
https://developers.google.com/android/reference/com/google/android/gms/fitness/FitnessActivities
Is there a way to add this particular activity type through the Google Fit SDK? I know I can just set a different name with a Session.Builder.setName method, but that wouldn't be sufficiently localised.
This will be available in the next SDK release.
Activity types are just String literals, so I believe you could just use "guided_breathing" in the interim.
I realized that when calling "createFile", it creates a new file even if its title is an already existing title.
What am doing now is to search for the file first and if i can't find it, i create it. Two methods for a simple problem.
There is a better way to create a file overriding it if already it exists?
Google Drive is actually a 'flat' model, where every object is identified by it's unique ID.
So, when an object (file/folder) is created, it gets a unique ID. The object may/not have content. Everything else is 'metadata'. The tree structure of popular OSs is actually 'faked' by metadata links (parent links). That means in Google Drive you may have multiple children with the same metadata (title/name) in a parent object. And you may also have multiple parents for any child object (single object appears in multiple parents' folders).
All this rant means one thing for your situation:
Once you create a file/folder and get hold of it's ID, 'creation of a new file with the same name' can be accomplished by modifying it's content and/or metadata (you can see a typical example here).
If you take the path of delete/create (which is also possible, but had not been until recently), you are actually:
1/ modifying the original file/folder's 'trashed/deleted' metadata
2/ creating a brand new object with a different ID
Think twice before you select the method you use. UPDATE method is a 'one-step', approach preferable in async environment (create MUST wait for successful delete). On the other hand, if you use DELETE/CREATE approach you may be able to take advantage of the fact that 'trashed' object will be around for a while.
Good Luck
I think files are uniquely identified by their ID in the Drive API. Therefore you have no way to control for the title using the drive API itself. So doing it yourself is probably the way to go.
EDIT: The ID is what is important with all that synchronisation happening. A title could change easily therefore using it as a unique identifier would be a bad idea. Hence the unique ID.
What you could do if the file already exists is either remove it and replace it by the new one (bad idea I would say) or simply add an extra number at the end of the new file that will be added to the folder.
I have been reading the Facebook documentation. The Facebook documentation for asking/sending gifts mentioned a YOUR_OBJECT_IDfor this call:
FB.ui({method: 'apprequests',
message: 'Take this bomb and blast your way to victory!',
to: 'RECIPIENT_USER_ID'
action_type:'send',`enter code here`
object_id: 'YOUR_OBJECT_ID', // Where do I get this ?
data: 'Friend Smash Custom Tracking 1'
}, function(response) {
console.log(response);
});
How do I get get it? I have already created my object inside Open Graph, but there is no object id specified. Do I need to initiate a create request for the user from my app for that object or how is this suppose to work?
The request_object_id is what you will get back from the dialog, after the user sent the gift – it is part of the dialog’s return value. It is simply the identifier for the request that was send.
https://developers.facebook.com/docs/games/requests/v2.1#response
You can use it to read details of the request back from the API.
OK, so since this is about the object id that one can pass to the dialog:
That documentation section already links to https://developers.facebook.com/docs/sharing/opengraph/custom, where this is explained in more detail.
Basically, you need to set up your own Open Graph action and Open Graph object. This will define what your object is, and what players of the game can do with it.
Open Graph objects can be created in two ways:
You can host them yourself. To do this, you simply provide URLs to HTML pages which include the Open Graph meta data that specifies the object property values. Facebook will then read the meta data from those URLs (“scraping”). In that case, you would simply pass the object URL to the dialog as object_id.
You can use the Object API to create objects that Facebook will host for you. These can either be “app-owned” or “user-owned” – depends on if the are specific to a certain user, or “common” objects to be used by all users of your app. Creating an object via that API will give you back an object id, that you can then pass to the dialog.
If you are not familiar with the whole Open Graph Story concept yet, then I recommend you start by having a look at the whole Open Graph section, https://developers.facebook.com/docs/sharing/opengraph
I am doing direct queries to wikipedia's website via an android app.
However, sometimes when I get "REDIRECT" queries, and my redirect suggestion has a # sign in it, I don't really know how to handle it. I know I can just throw everything out past the # sign, but that means I'm looking up something that is relatively unimportant.
Here is an example link;
http://en.wikipedia.org/w/api.php?action=query&prop=extracts&titles=Poof_(The_Fairly_OddParents)&format=json
I can just redirect to List_of_The_Fairly_OddParents_characters, but I want to know if there is anything useful I can do with the "#Poof" because I'm sure that the information is there for a reason.
I could not find anything on MediaWiki APIs.
Please help!
Thanks
Most of the time the part after the hash is a section title (though it is simply appended to the new URL, so it can be, and occasionally is, used to point to other kinds of anchors), so you can locate the section (with the mobileview action for example) and with the section index you can query the HTML for that section. (extracts does not support sections, so you you must use something else and enforce length limits manually.)
The hash points to a named anchor or ID in the target document. So if you're parsing the page content, then ideally you'd find the anchor tag or ID and return the content that follows that element, rather than starting at the beginning of the content.
I referred https://developers.facebook.com/docs/opengraph/location_tagging/
While trying to publish checkin, I passed place as place=(some url like "http://www.example.com/jeffys_burgers.html") along with lat,long coordinates and facebook user_id from android app,it
responds {"error":{"message":"(#100) Requires a valid Place Page ID","type":"OAuthException","code":100}}.
My query is how to specify actions,object type in my facebook app so that I can pass appropriate arguments from android app, for publishing checkin at a custom place ?
In the documentation you link to (in the section "Specifying Object Type") they create an object type called "Venue" of the type "Place". You have to do something similar. You don't have to call it "Venue" though.
Remeber that the object type Place is a "Facebook Place". Your jeffys_burgers.html should have og:type=yournamespace:venue (if you decide to call your object type "Venue"), and have the place:location:latitude and place:location:longitude set.