i trying use api , not getting anywhere. documention says "the document fax written directly request input stream in binary format"
i have tried using examples web like....
$xsendurl = 'http:/example.com/default.ashx?opt=sendfax&username=johndoe...'; # new data $data = array('filedata' => '@/data/html/sites/support/faapi/test.tif'); # create connection $ch = curl_init(); # setting our options curl_setopt($ch, curlopt_url, $xsendurl); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_postfields, $data); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_binarytransfer, 1); curl_setopt($ch, curlopt_verbose, 1); # response $response = curl_exec($ch); curl_close($ch); but when check file created on server contents of file path defined $data variable. (@/data/html/sites/support/faapi/test.tif)
i new @ php. looked php://input , php://outout not sure if work.
on url use invoke api pass filename, username, , security tokens not sure how grab request input stream upload file after opening url.
any appreciated.
thanks
i try using file_get_contents() specialized stream. works follows:
create "context" description how http request should formed:
- use post request
- send additional header content-type: image/tiff
- include contents of tiff file
request api url using specified context.
skeleton code:
$data = file_get_contents('/data/html/sites/support/faapi/test.tif'); $options = array('http' => array( 'method' => 'post', 'header' => 'content-type: image/tiff', 'content' => $data, ) ); $context = stream_context_create($options); $result = file_get_contents($xsendurl, false, $context);
Comments
Post a Comment