Jump to content

Help with PHP request to efax development server


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.