0

I'm going to select data which return value from third party website as below Json objects format and that website build in Java languages and tomcat database.

Issue How to get contain from that websites?

Server description

URL:http://103.5.126.24/PalmHallServer/coodraw/coodraw!queryAllProduct.action

Return data json objects, luckDrawProductList for all product information array,

{
    "LuckDrawProductList": [
        {
            "BaseTime": 20140119133000,
            "CommissionRatio": 10,
            "DeductBetCount": 1,
            "Detail": "You can enter any amount between ...",
            "Enable": 1,
            "FreeResDiscount": 1,
            "LotteryTime": 20151016164500,
            "LuckDrawDesc": "DRAW1",
            "LuckDrawDiscount": 1,
            "MaxLuckNumLen": 5,
            "MaxMoney": 2000000,
            "MinLuckNumLen": 5,
            "MinMoney": 100,
            "NextStartTime": "2015-10-16 12:00:00",
            "NextStopTime": "2015-10-16 16:15:00",
            "OpenDrawType": -1,
            "PeriodUnit": 1,
            "PeriodUnitNum": 1,
            "Price": 40,
            "ProductCode": "DRAW1",
            "ProductDesc": "Draw1",
            "ProductEndTime": 20990119163000,
            "ProductId": 11111,
            "ProductType": 11,
            "Rate": 0,
            "ResTmplProductId": 11111,
            "StopTime": 1800,
            "ValidPeriod": 2
        }
    ],
    "Period": "201510161645"
}
2
  • 1
    are you using Gson? @Cambodia_channel Commented Oct 26, 2015 at 12:21
  • I want to httpClient in PHP because my teamwork seguested me to use it Commented Oct 26, 2015 at 12:22

1 Answer 1

2

Please try code below

$URL = "http://103.5.126.24/PalmHallServer/coodraw/coodraw!queryAllProduct.action";

$content = file_get_contents($URL);    // get json data using file_get_content
$content_arr = json_decode($content); // json data to php array.

OR if you wish to use curl

$s = curl_init(); 
curl_setopt($s,CURLOPT_URL,$this->_url);
curl_setopt($s,CURLOPT_RETURNTRANSFER,true);    
$result = curl_exec($s);
curl_close($s);
$content_arr = json_decode($result); // json data to php array.

Then you could print_r($content_arr) and check "LuckDrawProductList" the key or access $content_arr['LuckDrawProductList][0]

Sign up to request clarification or add additional context in comments.

2 Comments

I got errors Fatal error: Call to undefined function file_get_content() in D:\My data\project\wamp\www\lottery\application\views\templates\content.php on line 83
welcome and sorry for file_get_content , I have changed it to file_get_contents

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.