Link to home
Start Free TrialLog in
Avatar of Nico2011
Nico2011Flag for United Kingdom of Great Britain and Northern Ireland

asked on

JSON-RPC Feed - PHP/JavaScript


I have two PHP files (attached) - file1.txt (should be PHP) works, the other, file2.txt (PHP) doesn't... the first one doesn't call any fields from the feed, the second does.

I download the data into a local file for processing - my file gets created in both instances, however the second file creates a file with only 1k size, whereas the file should be far larger.

I receive an OxFF message from Windows Scheduler when I run the PHP file.

HELP - please!

Thanks in advance.
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nico2011


YES Julian - that's EXACTLY what I meant ;-)<br /><br />I'm new to PHP, so will do many silly things...<br /><br />Thanks very much - works a dream!
Just guessing, but might this be what you want?  If you have any documentation on how to use the web service it might give an example.

<?php // RAY_temp_nico2011.php
ini_set('max_execution_time', 300);

/* THIS STATEMENT IS FALSE: Methodname is part of the URL */
/* The JSON method name is part of the URL. use only lowercase characters in the URL */

$url = "";

$post_data = array
( 'jsonrpc' => '2.0'
, 'method'  => 'ListOfHousesV1'
, 'params'  => array
  ( 'WebpartnerCode'     => 'XXXXXXXX',
    'WebpartnerPassword' => 'XXXXXXXX',
    'SelectionFields' => array
                        ( 'MaxNumberOfPersons'
                        , 'Country'
                        , 'HouseType'
, 'id'      => 461930148

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('content-type: application/json'));  /** For large amounts of data use compression for better performance :curl_setopt($ch, CURLOPT_HTTPHEADER, array('content-type: application/json','Accept-Encoding: gzip,deflate'));  **/
curl_setopt($ch, CURLOPT_SSLVERSION,3); /* Due to an OpenSSL issue */
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);  /* Due to a wildcard certificate */
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_ENCODING, 1); /* If result is gzip then unzip */
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

if ($result = curl_exec($ch))
    if ($res = json_decode($result))
        file_put_contents('c:\data\ListOfHouses.txt', $result);
    else echo json_last_error();
    echo curl_error($ch);


Open in new window

I'm new to PHP, so will do many silly things...
I guarantee there is not an expert here who did not go through this stage.

Glad to help - keep at it.

Thanks for the points
Hi Ray,

Thanks for your answer too - I had first received Julian's response - yours must have come in as I was answering Julian's - your code from the other day worked perfectly - I just needed to add the array.

Thanks again and best wishes/Nico