question

Jeremy Simkins avatar image
Jeremy Simkins asked ·

No recipients specified PHP api

No matter what I do I get the error: No recipients specified

I am using the API in PHP as:
$url = "https://service.ringcentral.com/faxapi.asp";
$faxData = array(); $faxData['Username'] = "xxxxxxx"; $faxData['Password'] = "xxxxxxx"; $faxData['Recipient'] = $faxNumber; $faxData['Attachment'] = ROOT_PATH.$fileLocation; $rs = fetch_url_post($url, $faxData);
function fetch_url_post($url, $variable_array){          $fields_string = "";          //set POST variables          $fields=array();          foreach($variable_array as $key => $value){              $fields[$key] =  urlencode($value);          }            //url-ify the data for the POST          foreach($fields as $key=>$value) {              $fields_string .= $key."=".$value."&";          }          rtrim($fields_string, '&');            //open connection          $ch = curl_init();            //set the url, number of POST vars, POST data          curl_setopt($ch,CURLOPT_URL, $url);          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);          curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);          curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);          curl_setopt($ch,CURLOPT_POST, count($fields));          curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);            //execute post          $result = curl_exec($ch);          $err = curl_errno ( $ch );          $errmsg = curl_error ( $ch );          $header = curl_getinfo ( $ch );          $httpCode = curl_getinfo ( $ch, CURLINFO_HTTP_CODE );            //close connection          curl_close($ch);            switch($result) {              case '0':                  echo 'Successful';                  break;              case '1':                  echo 'Authorization failed';                  break;              case '2':                  echo 'Faxing is prohibited for the account';                  break;              case '3':                  echo 'No recipients specified';                  break;              case '4':                  echo 'No fax data specified';                  break;              case '5':              default:                  echo 'Generic error';                  break;          }            return $result;      }
No matter what I do I always get the error: No recipients specified

I even tried with the wrong login credentials to get a different error but I only get: No recipients specified.

What is causing this?

UPDATE:
I am now able to get a different response... finally. I changed my function to this to use the cert as is is unsigned.
function fetch_url_post($url, $variable_array){          $fields_string = "";          //set POST variables          $fields=array();          foreach($variable_array as $key => $value){              $fields[$key] =  urlencode($value);          }            //url-ify the data for the POST          foreach($fields as $key=>$value) {              $fields_string .= $key."=".$value."&";          }          rtrim($fields_string, '&');            //open connection          $ch = curl_init();    //        fff_die(curl_version());            //set the url, number of POST vars, POST data          curl_setopt($ch,CURLOPT_URL, $url);          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);    //        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);  //        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);              curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);          curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);          curl_setopt($ch, CURLOPT_CAINFO, ROOT_PATH."_cache/ringcentral.crt");            curl_setopt($ch,CURLOPT_POST, count($fields));          curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);            //execute post          $result = curl_exec($ch);          $err = curl_errno ( $ch );          $errmsg = curl_error ( $ch );          $header = curl_getinfo ( $ch );          $httpCode = curl_getinfo ( $ch, CURLINFO_HTTP_CODE );            //close connection          curl_close($ch);            switch($result) {              case '0':                  echo 'Successful';                  break;              case '1':                  echo 'Authorization failed';                  break;              case '2':                  echo 'Faxing is prohibited for the account';                  break;              case '3':                  echo 'No recipients specified';                  break;              case '4':                  echo 'No fax data specified';                  break;              case '5':              default:                  echo 'Generic error';                  break;          }              fff_die(array(              $result,              $err,              $errmsg,              $header,              $httpCode          ));            return $result;      }
I have the cert in the path specified and now I get the error:SSL certificate problem: self signed certificate in certificate chain

This is getting very frustrating. Why do I have to do this cert work-a-round in the first place? Is there something wrong with the code or is this a ringcentral issue?

Any help on this is very much appreciated.

Thanks,
Jeremy

apierror
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

0 Answers

· Write an Answer

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Customer Spaces