Account confirmers, Anti-spam team, Confirmed users, Bureaucrats and Sysops emeriti
4,925
edits
No edit summary |
|||
| Line 3: | Line 3: | ||
==Example== | ==Example== | ||
Here is a simple example using XHR. It will return any bugs that you have ever commented on, that were also changed in the last day. | Here is a simple example in JavaScript using XHR. It will return any bugs that you have ever commented on, that were also changed in the last day. | ||
<pre> | <pre> | ||
function | function handleResponse(response) | ||
{ | { | ||
var output = ""; | var output = ""; | ||
var bugs = | var json = JSON.parse(response); | ||
var bugs = json.bugs; | |||
for (var i = 0; i < bugs.length; i++) { | for (var i = 0; i < bugs.length; i++) { | ||
output += bugs[i].id + " " + bugs[i].summary + "\n"; | output += bugs[i].id + ": " + bugs[i].summary + "\n"; | ||
} | } | ||
| Line 19: | Line 20: | ||
function progressListener() { | function progressListener() { | ||
if(this.readyState == 4 && this.status == 200) { | if (this.readyState == 4 && this.status == 200) { | ||
handleResponse(this.responseText); | |||
} | } | ||
} | } | ||
function | function getMyActiveBugs(bugzillaLogin) | ||
{ | { | ||
var | var apiURL = "https://api-dev.bugzilla.mozilla.org/0.2/bug" . | ||
"?email1=" + bugzillaLogin + | |||
"&email1_type=equals_any&email1_comment_author=1" + | |||
"&changed_after=1d&changed_before=Now"; | |||
var client = new XMLHttpRequest(); | var client = new XMLHttpRequest(); | ||
client.onreadystatechange = progressListener; | client.onreadystatechange = progressListener; | ||
client.open("GET", | client.open("GET", apiURL); | ||
client.setRequestHeader('Accept', 'application/json'); | client.setRequestHeader('Accept', 'application/json'); | ||
client.setRequestHeader('Content-Type', 'application/json'); | client.setRequestHeader('Content-Type', 'application/json'); | ||
| Line 41: | Line 40: | ||
} | } | ||
getMyActiveBugs("gerv@mozilla.org"); | |||
</pre> | </pre> | ||