Jump to content

Help with PHP request to efax development server


mo

Recommended Posts

I signed up for an efax accont and I am currently trying to send a outbound text fax. I have the following directions but I am unsure how to proceed. I have written code to format my XML message but do not know how to send the request. I have completed the items in blue but I am stuck on the items in red. I am a PHP newbee.

 

Instructions:

The following is provided as a high-level overview of expected client-side outbound request processing.

 

• Open a TCP/IP socket or URL connection using the URL address for eFax Developer™. The secure eFax Developer™ URL is https://secure.efaxdeveloper.com/EFax_WebFax.serv.

 

• Set the request header section to specify the HTTP POST method, set the Content-type to be “application/x-www-form-urlencoded.”

 

• Create an XML-formatted message meeting all requirements as explained in this document.

 

• URL-encode the XML-formatted message.

 

• Send your request to eFax Developer™. To send a request, an application writes a stream of data to eFax Developer™ via a TCP/IP socket or URL connection. The data stream must be in the form of an HTTP POST request message. The request will consist of two arguments, an Account Identifier (“id”); provided at setup time; and your XML-formatted data (“xml”). Optionally, you may send a third argument to indicate the desired response type (“respond”) of “HTML” (default) or “XML.”

$xml = your xml string

$id = your account id

$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,'https://secure.efaxdeveloper.com/EFax_WebFax.serv');
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,array('id'=>$id,'xml'=>$xml));
curl_exec($ch);

Below:

 

Post Unsuccessful!

 

Your request has failed due to invalid data.

 

Please refer to our documentation prior to resubmitting.

 

Error Level: User

Error Message: Account identifier argument was not passed.

 

Please contact us at 888-278-8666 if you continue to encounter errors.

Below:

 

Post Unsuccessful!

 

Your request has failed due to invalid data.

 

Please refer to our documentation prior to resubmitting.

 

Error Level: User

Error Message: Account identifier argument was not passed.

 

Please contact us at 888-278-8666 if you continue to encounter errors.

 

did you set $id to your account id?

Yes, I set the ID variable before I call your code.

 

curl_setopt($ch,CURLOPT_POSTFIELDS,array('id'=>$id,'xml'=>$xml));

 

I changed the CURLOPT_POSTFIELDS to use a string for fields, i.e. $fields = 'id='.$id.'&xml='.$xml; and this worked but I still received an erorr but I think I can fix this.

 

I now receive Error Message: File contents are not Base64 encoded.

 

I just changed urlencode to base64_encode for my XML string and I now recieve error "XML data argument was not passed.".

Here is my code:

 

$id  = '6785555555';

$xml = order_to_fax('5',$id);

 

$fields = 'id='.$id.'&xml='.base64_encode($xml);

 

$ch = curl_init();

curl_setopt($ch,CURLOPT_URL,'https://secure.efaxdeveloper.com/EFax_WebFax.serv');

curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);

curl_setopt($ch,CURLOPT_POST,true);

curl_setopt($ch,CURLOPT_POSTFIELDS,$fields);

curl_exec($ch);

it builds an XML string based on a order in my database. I checkd the XML and the structure/format looks good. I think the error is due to Curl not handling the XL properly. I am looking at some post on other sites and I see alot of people have issues posting XML with curl.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.