OT - need help with PHP
bgailer at gmail.com
Fri Feb 1 15:07:01 EST 2019
Thank you for your various responses. All helpful and encouraging.
RE mailing list: I followed the instructions at
I have had no response. Shouldn't I get something either welcoming me to
the list or requesting a confirmation?
Here are the instructions from the api vendor: (somewhat lengthy)
HOW TO CALL A FUNCTION USING VOIP.MS REST/JSON API
The following samples show how to get all Servers Information from our
database and how to select a specific Server for your display purposes.
- When using our REST/JSON API you need to send the Method to be used
and the Required Parameters as part of the URL.
- By default the output Content-Type is "text/html".
- If you want the output Content-Type to be "application/json", add the
following to your URL: &content_type=json
PHP - Using cURL GET - Sample Code
|$ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
$result1 = curl_exec($ch); curl_close($ch);
PHP - Using cURL POST - Sample Code
|$postfields = array( 'api_username'=>'john at domain.com',
'server_pop'=>'1'); $ch = curl_init(); curl_setopt($ch,
CURLOPT_RETURNTRANSFER, true ); curl_setopt($ch, CURLOPT_POST, true );
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); curl_setopt($ch,
CURLOPT_URL, "https://voip.ms/api/v1/rest.php"); $result =
curl_exec($ch); curl_close($ch); $data=json_decode($result,true);
Note: I have edited these examples by removing unnecessary stuff, to
make their size reasonable.
On the Python side, I can make the GET version work using
urllib.request. I will try requests soon.
When I try to run the post example using php -r "path-to-php-progran";
It just prints the program.
Any attempt at converting that to POST get me a Bad Request response.
One of my needs is to upload a .wav file. The vendor requires the file
to be encoded into base64 and the result string included in the POST
data, which can lead to enormously long POST data. I can successfully
use GET to send very short .wav files, but the url length limit is
quickly reached for a reasonable length recording. Trying to use the
POST ability that allows me to specify the file by path fails at the
Apology for long post, but I don't know what to omit. Again any help is
This email has been checked for viruses by Avast antivirus software.
More information about the Python-list