Adding an item to wedata with Greasemonkey API


var opts = {
    url: "http://wedata.net/databases/AutoPagerize/items",
    method: "POST",
    headers:{"Content-Type":"application/x-www-form-urlencoded"},
    data: [
        ["api_key", YOUR_WEDATA_APIKEY],
        ["name", document.title ],
        ["data[nextLink]", nextLinkXPath ],
        ["data[pageElement]", pageElementXPath ],
        ["data[url]=", urlRegex ],
    ].map( function (a) {
        return a[0] + "=" + encodeURIComponent(a[1]);
    } ).join("&"),
    onload: function (res) {
        console.log({ res: res, opts: opts});
    }
};
GM_xmlhttpRequest( opts );

response from wedata:


Date: Wed, 23 Apr 2008 02:56:32 GMT
Server: Mongrel 1.1.4
Status: 201 Created
Location: http://wedata.net/items/879
X-Runtime: 0.14564
changed June 4, 2011 delete history edit