RemoveBookmark.java Source code

Java tutorial

Introduction

Here is the source code for RemoveBookmark.java

Source

/**
 * NZBMatrixLib provides an intuitive java interface library to interact with the API provided by (http://www.nzbmatrix.com)
 *
 * The author(s) of NZBMatrixLib are in NO WAY associated with (http://nzbmatrix.com) or its affiliates
 *
 * If you  would like to contribute to this library, find us at (https://github.com/TheBigS/NZBMatrixLib)
 *
 *   Copyright (C) 2010  Steven King
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
import java.io.IOException;
import java.text.ParseException;

import org.apache.http.client.ClientProtocolException;

import com.github.thebigs.nzbmatrixapi.ApiCredentials;
import com.github.thebigs.nzbmatrixapi.NZBMatrixApi;
import com.github.thebigs.nzbmatrixapi.NZBMatrixApiException;
import com.github.thebigs.nzbmatrixapi.response.BookmarkResponse;

public class RemoveBookmark {
    private static String USER_NAME = "<YOUR USER NAME>";
    private static String API_KEY = "<YOUR API KEY>";

    /**
     * @param args
     * @throws ParseException
     */
    public static void main(final String[] args) throws ParseException {
        // you can either set the 2 strings above, or pass them in to this program
        if (args.length == 2) {
            USER_NAME = args[0];
            API_KEY = args[1];
        }

        // make sure the credentials got set
        if (USER_NAME.equals("<YOUR USER NAME>") || API_KEY.equals("<YOUR API KEY>")) {
            System.err.println(
                    "You must either edit this example file and put in your username and apikey OR pass them in as program arguments");
            System.exit(1);
        }

        final ApiCredentials credentials = new ApiCredentials(USER_NAME, API_KEY);

        final NZBMatrixApi api = new NZBMatrixApi(credentials);

        try {
            // makes the request to the nzbMatrixAPI for to remove a bookmark on a particular post id
            final BookmarkResponse bookmarkResponse = api.removeBookmark(314694);

            // print out the info returned by the Bookmarks API
            System.out.println("Result: " + bookmarkResponse.getResult());
        } catch (final ClientProtocolException e) {
            e.printStackTrace();
        } catch (final IOException e) {
            e.printStackTrace();
        } catch (final NZBMatrixApiException e) {
            e.printStackTrace();
        }
    }
}