Technical Description

Request Format

You use the API by passing parameters to specific endpoint URLs using HTTP GET and POST as documented below. Here is a Java example for adding a new blog entry:

// Write a new entry into webs user superdave23's blog! 
String contenttype = "application/x-www-form-urlencoded"; 
String webs_user = "superdave23";    
String webs_pass = “password123”;  
String target =    
    "http://api.webs.com/v1/sitemanager/"+webs_user+"/pages/blog"; 

try { 
    URL url = new URL(target); 
    URLConnection urlConn = url.openConnection(); 
    urlConn.setDoOutput(true); 

    // Set content-type 
    urlConn.setRequestProperty("Content-Type", contenttype); 

    // Send POST parameters 
    OutputStream ots = urlConn.getOutputStream(); 
    DataOutputStream request = new DataOutputStream(ots); 

    String content =  
        "password=" + URLEncoder.encode(webs_pass, "utf-8") +  
        "&title=" + URLEncoder.encode("Did you ever wonder?", "utf-8") +  
        "&body=" + URLEncoder.encode("Today I saw my friend", "utf-8"); 

    request.writeBytes(content); 
    request.flush(); 
    request.close(); 

    // Get response  
    InputStream ins = urlConn.getInputStream(); 
    BufferedReader response = new BufferedReader(new InputStreamReader(ins)); 
    String str; 

    // Print response 
    while (null != ((str = response.readLine()))) { 
        System.out.println(str); 
    } 
    response.close(); 
} 
catch (IOException ex) { 
}

Response Format

The response to each API call is in the form of an XML document (alternatively a JSON document in the future). Each response follows the format described below.

A successful call returns an XML document in the following format:

<?xml version="1.0" encoding="utf-8" ?> 
<rsp stat="ok"> 
    [xml-payload-here]   see examples below 
</rsp>

A call returns an XML document in the following format when an error occurs:

<?xml version="1.0" encoding="utf-8" ?> 
<rsp stat="fail"> 
    <err code="[error-code]" msg="[error-message]" /> 
</rsp>

Error Codes:

Generic error codes include:

Code Response
100 Received unexpected information
110 Did not receive enough information
997 API key is not valid
998 Webs.com is down for maintenance. Please try again later
999 [handler name] is not known

Comments

  1. kumara1 year ago

    // Write a new entry into freewebs user superdave23's blog!
    String contenttype = "application/x-www-form-urlencoded";
    String freewebs_user = "superdave23";
    String freewebs_pass = “password123”;
    String target =
    "http://api.freewebs.com/v1/sitemanager/"+freewebs_user+"/pages/blog";

    try {
    URL url = new URL(target);
    URLConnection urlConn = url.openConnection();
    urlConn.setDoOutput(true);

    // Set content-type
    urlConn.setRequestProperty("Content-Type", contenttype);

    // Send POST parameters
    OutputStream ots = urlConn.getOutputStream();
    DataOutputStream request = new DataOutputStream(ots);

    String content =
    "password=" + URLEncoder.encode(freewebs_pass, "utf-8") +
    "&title=" + URLEncoder.encode("Did you ever wonder?", "utf-8") +
    "&body=" + URLEncoder.encode("Today I saw my friend", "utf-8");

    request.writeBytes(content);
    request.flush();
    request.close();

    // Get response
    InputStream ins = urlConn.getInputStream();
    BufferedReader response = new BufferedReader(new InputStreamReader(ins));
    String str;

    // Print response
    while (null != ((str = response.readLine()))) {
    System.out.println(str);
    }
    response.close();
    }
    catch (IOException ex) {
    }

Please sign in to post a comment.