Jefferson Bien-Aime

My feedback

  1. 7 votes
    Vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    4 comments  ·  Bible Search  ·  Flag idea as inappropriate…  ·  Admin →
    Jefferson Bien-Aime commented  · 

    Hi Francis, I hope it is not too late. This is the example in Java. Like David said, I left the password blank and put the token in the username. I hope this work.

    Blessings

    import java.io.BufferedReader;
    import java.io.DataOutputStream;
    import java.io.InputStreamReader;
    import java.net.HttpURLConnection;
    import java.net.URL;
    import org.apache.commons.codec.binary.Base64;

    import javax.net.ssl.HttpsURLConnection;

    /**
    *
    * @author jeffersonbienaime
    */
    public class BibleSearchQuery {

    /**
    * @param args the command line arguments
    * @throws java.lang.Exception
    */
    public static void main(String[] args) throws Exception {

    BibleSearchQuery http = new BibleSearchQuery();

    System.out.println("Testing 1 - Send Http GET request");
    http.sendGet();

    }

    private void sendGet() throws Exception {

    String url = "http://bibles.org/v2/verses/fra-LSG:Acts.8.34.xml";

    URL obj = new URL(url);
    HttpURLConnection con = (HttpURLConnection) obj.openConnection();
    String username = "your token";
    String password = "";
    String user_pass = username + ":" + password;
    String encoded = Base64.encodeBase64String(user_pass.getBytes());
    con.setRequestProperty("Authorization", "Basic " + encoded);

    // optional default is GET
    con.setRequestMethod("GET");
    System.out.println("\nSending 'GET' request to URL : " + url);
    System.out.println("Response Code : " + con.getResponseCode());
    System.out.println("Response Message : " + con.getResponseMessage());

    BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
    String inputLine;
    StringBuffer response = new StringBuffer();

    while ((inputLine = in.readLine()) != null) {
    response.append(inputLine);
    }
    in.close();

    //print result
    System.out.println(response.toString());

    }

    }

  2. 5 votes
    Vote
    Sign in
    (thinking…)
    Sign in with: Facebook Google
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    3 comments  ·  Bible Search  ·  Flag idea as inappropriate…  ·  Admin →
    Jefferson Bien-Aime commented  · 
    Jefferson Bien-Aime supported this idea  · 

Feedback and Knowledge Base