Fax
Our Fax provider is PamFax.
Their API is described here and they have a Java SDK for using it.
From their website -
Java SDK Sample
Below you can see sample code to send a fax via our Java library. This sample doesn’t include a UI implementation, because it is dependant on the target platform.
All main API classes are present in the library, their names starts with ‘API’ prefix. In these classes, you may find all needed methods to work with the API. Each method may be used as stand-alone static call with specifiedrequestListener (instance of SessionListener) parameter that uses to handle request response:
// Pre-define a request listener for post-request work SessionListener requestListener = new SessionListener() { public void onRequestComplete( RequestType requestType, int resultCode, ResponseData responseData ) { // Checking for successful request result if ( resultCode == ResultCode.SUCCESS ) ... else ... // To do some additional things depending on request type switch ( requestType ) { case SESSION_VERIFY_USER: ... UserInfo userInfo = responseData.getUserInfo(); ... break; default: break; } } }; // Verifying the user using static call APISession.verifyUser( "userName", "password", requestListener ); |
Also there are some classes to do your work easier:
• SessionHelper that may be used to handle of a API session and an user session.
• FaxJobHelper to semiautomated processing of APIFaxJob requests.
Here is an example how to use these classes in your program code:
// Pre-define a session listener for post-requests work SessionListener sessionListener = new SessionListener() { public void onRequestComplete( RequestType requestType, int resultCode, ResponseData responseData ) { // Checking for successful request result if ( resultCode == ResultCode.SUCCESS ) ... else ... // To do some additional things depending on request type switch ( requestType ) { case FAXJOB_ADD_FILE: ... FaxFileContainer fileContainer = responseData.getFaxFileContainer(); ... break; case FAXJOB_ADD_RECIPIENT: ... FaxRecipient recipient = responseData.getFaxRecipient(); ... break; case FAXJOB_CREATE_FAX: ... FaxContainer faxContainer = responseData.getFaxContainer(); ... break; case FAXJOB_SEND_FAX: ... break; case SESSION_VERIFY_USER: ... UserInfo userInfo = responseData.getUserInfo(); ... break; default: break; } } }; // Creating SessionHelper object to automate some API session work SessionHelper sessionHelper = new SessionHelper( API_KEY, API_SECRET, sessionListener ); // Starting API user session sessionHelper.startSession( "userAccount", "userPassword", true ); // Creating FaxJobHelper object to automate some fax job tasks FaxJobHelper faxJobHelper = new FaxJobHelper( sessionListener, SEND_REPEAT_TIMEOUT, SEND_REPEATS_COUNT ); // Creating new fax container faxJobHelper.createFax(); // Adding fax recipient faxJobHelper.addRecipient( "+1991234567", "John Doe" ); // Adding file which one of supported formats File faxFile = new File( "path/to/my/file.docx" ); faxJobHelper.addFile( "myFileToFax.docx", faxFile ); // Sending fax. If fax yet not ready, FaxJobHelper will retry sending // with specified SEND_REPEAT_TIMEOUT and SEND_REPEATS_COUNT faxJobHelper.sendFax();