You cannot use a standard GET
request.You cannot use a standard GET
request. You must obtain the access_token
and then POST
the necessary parameters.
The steps are currently:
Setup:
- Register your app.Register your app.
- Link it with a post here on Stack Apps that has a legitimate [app] or [script] taga post here on Stack Apps that has a legitimate [app] or [script] tag. In most cases you will also tag it with placeholder.
In your app:
- Have the user authorize your app and obtain an
access_token
by following the instructions in the Authentication doc page. Be sure to includewrite_access
in the requested scope.
Note that there are two different auth recipes: explicit and implicit.
Which one you are allowed to use is controlled by the Client Side Flow setting on your app's registration page (visible only to you)your app's registration page (visible only to you).
If Client Side Flow is Enabled use the "implicit" recipe.
Otherwise, use the "explicit" steps.
For faster and easier code, use a librarya library or use the JavaScript SDK to handle authentication.
Send a
POST
tohttps://api.stackexchange.com/2.2/questions/{id}/favorite
with the following parameters at a minimum:
id
= {The question id -- same as in the POST URL}
key
= {Your app's key}
site
= stackoverflow //-- Or whatever site you're operating on
preview
= false
access_token
= {The access token you obtained in step 1}
On success, the API will return JSON with a question object. EG:
{ "items": [ ... {question details} ... ], "has_more": false, "quota_max": 10000, "quota_remaining": 9996 }