How to Integrate InterFAX's Inbound and Outbound fax facility in PHP

8 posts / 0 new
Last post
webintegrated
Offline
Joined: 27 Jun 2005
How to Integrate InterFAX's Inbound and Outbound fax facility in PHP

One of our client have an account with your interfax.net site having the username as “crackiswack” and want to integrate your Inbound as well as Outbound fax facility in our site debtsettlementnetwork.com that is built in PHP.

We got a sample code from your site to send fax which is as follows,

<?
/**
* Send a Fax using PHP/PEAR::SOAP Example:
* - Using SendFaxEx() Method from InterFax Web Services
*/

/**
* Your variables go here - assign a value to each one
*/
$username = "crackiswack";
$password = ""; // password I am not mentioning here
$faxnumber = "+0018003100021";  // formatted like +13055551234, i.e. +(country code)(area code)(phone number)
$file = "documents/doc10.doc"; // binary file to fax
$filetype = "DOC"; //e.g. HTML, DOC, PDF, etc.; see documentation for complete list
$postponetime = "2005-04-25T20:31:00-04:00";  //e.g. 2001-04-25T20:31:00-04:00, use a past date/time to fax immediately
$resolution = "0"; // 0 for standard, 1 for fine
$csid = ""; // your fax identifier, visible on the receiving machine's little screen
$subject = "fax from Webintegrated"; // for your reference, visible in the outbound queue
$replyemail = "mfc_viks@yahoo.co.in"; //optional address at which to receive an emailed confirmation

/**
* PEAR::SOAP class [http://pear.php.net/package/SOAP]
*/
require_once 'SOAP/Client.php'; 

// Open File
if( !($fp = fopen($file, "r")))
{
// Error opening file
// Handle error how it is appropriate for your script
exit;
}

// Read data from the file into $data
$data = "";
while (!feof($fp)) $data .= fread($fp,1024);

// URL path to InterFax Web Services
$wsdl_url = 'http://ws.interfax.net/dfs.asmx?wsdl';

// Create an instance of the SOAP_WSDL class
$WSDL = new SOAP_WSDL($wsdl_url); 

/**
* This function creates a proxy to the SOAP services
* so that you can access the InterFax methods directly
* as if you were calling a local function
*/
$client = $WSDL->getProxy(); 

/**
* Invoke the InterFax SendFaxEx Method
* NOTE: 'base64_encode' is a native method in PHP [http://www.php.net/manual/en/function.base64-encode.php]
*/
$result = $client->SendFaxEx($username, $password, $faxnumber, base64_encode($data), $filetype, strlen($data), $postponetime, $resolution, $csid, $subject, $replyemail); 

// Echo Result
if($result > 0) echo "Fax submitted. Transaction ID: $result";
else echo "Error sending fax. Return code: $result";
?>

According to the above code, we need SOAP/client.php file. We have downloaded the complete SOAP package from the given URL (http://pear.php.net/package/SOAP) but this does not contain some files like PEAR.php, HTTP/Request.php etc. (for which it has shown us the errors while running it.)

Please let us know whether we are on right way or not?

Thanks
Developers
Web Integrated (India)

Adam M
Offline
Joined: 19 Jun 2009

Yes, you are absolutely on the right way.

The first thing, however, is to verify that your SOAP installation is complete. All of PEAR::SOAP's dependencies can be found on the PEAR website. (These are the files that we use internally. I'm not sure if these are the most up-to-date, but they do work on our installation)

Alternatively, for a SOAP installation with no dependencies, you can try the NuSOAP library. See the discussion related to sending a fax through NuSOAP.

webintegrated
Offline
Joined: 27 Jun 2005

Thanks for ur reply.

But let me tell u that i am using apache 2.0 on windows 2000 professional for the develoment of the site.

So can u tell me what steps should i follow to install SOAP on my machine.

Currently, what i did, i created a folder in my apache's root directory with the name "test" and copid all the folders HTTP,NET,SOAP in it. Written the above code in test.php file. But while runnig it, getting errors of missing few files. This time the error is

Warning: main(Net/Socket.php): failed to open stream: No such file or directory in C:\Apache\Apache2\htdocs\AJ\HTTP\Request.php on line 47

Please help me out.

Thanks

Adam M
Offline
Joined: 19 Jun 2009

Installing SOAP simply means copying the files to a location where you can reference them from within your script. So, if you have downloaded the bare minimum SOAP files for InterFAX, all you need to do is to update your include path and to include SOAP:

ini_set("include_path",'/path/to/inc' . ':' . ini_get("include_path"));
require_once 'SOAP/Client.php';

webintegrated
Offline
Joined: 27 Jun 2005

Please can u come over yahoo or hotmail or aol IM. We will be there as webintegrated.

abi
Offline
Joined: 29 Jun 2005

Does thsi work for you ? i have same problem i did all what you asked still give error .. can any one help me pls ..

Abi

Adam M
Offline
Joined: 19 Jun 2009

Abi,

webintegrated seemed to have a problem with his PEAR::SOAP installation. Instead of debugging it, I suggested that he install NuSOAP, using a trivial faxing example, and he had it running within minutes.

Simply download the latest version of NuSOAP and use this code:

<?php

require_once('nusoap.php');
$client = new soapclient("http://ws.interfax.net/dfs.asmx?wsdl", true);
$params[] = array('Username'        => '9999999',
                'Password'        => 'abcdefg',
                'FaxNumber'        => '+44-870-730-1444',
                'Data'            => 'My text goes here',
                'FileType'        => 'TXT'
                );

$result = $client->call("SendCharFax", $params);

echo $result["SendCharFaxResult"];

?>

Justec
Offline
Joined: 25 Jul 2005

Like Adam said you not only need to have the PEAR SOAP classes but all the base PEAR classes as well. A lot of web host provide the base classes in a shared directory that all web host clients can access, but you can always download all of them yourself and put in an "include" folder within your web hosting directory.

I know its been about a month since the last post so let me know if you were able to figure it out or not.

Login or register to post comments