Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- $url = 'url';
- $username = 'xxx';
- $password = 'xxx';
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
- curl_setopt($ch, CURLOPT_URL, $url);
- $data = "{
- "customerId":"A1234",
- "status": {
- "id": "2HIII41T24FNHOU2",
- "name": "Till salu"
- },
- "typeOfDate":0}";
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
- 'Content-Type: application/json',
- 'Content-Length: ' . strlen($data)
- ));
- $result = curl_exec($ch);
- if (curl_errno($ch)) {
- die(curl_getinfo($ch));
- }
- $info = curl_getinfo($ch);
- curl_close($ch);
- $http_code = $info["http_code"];
- if ($http_code == 401) {
- // Username password wrong
- }
- if ($http_code == 403) {
- }
- if ($http_code == 500) {
- }
- if ($http_code == 400) {
- $json = json_decode($result, true);
- }
- print_r($result);
- ?>
- [
- {
- "customerId": "sample string 1",
- "houses": [
- {
- "livingSpace": 1.1,
- "rooms": 1.1,
- "price": 2.1,
- "id": "sample string 3",
- "status": {
- "id": "sample string 1",
- "name": "sample string 2"
- },
- "customerId": "sample string 4",
- "areaName": "sample string 5",
- "dateChanged": "2017-04-18T11:41:14.4606538+02:00",
- "streetAddress": "sample string 6",
- "coordinate": {
- "longitud": 1.1,
- "latitud": 2.1
- },
- "shortSaleDescription": "sample string 7",
- "viewingsList": [
- {
- "startTime": "2017-04-18T11:41:14.4606538+02:00",
- "endTime": "2017-04-18T11:41:14.4606538+02:00"
- },
- {
- "startTime": "2017-04-18T11:41:14.4606538+02:00",
- "endTime": "2017-04-18T11:41:14.4606538+02:00"
- }
- ],
- "bidding": true,
- "mainImage": {
- "imageId": "sample string 1",
- "dateChanged": "2017-04-18T11:41:14.4606538+02:00",
- "dateChangedImageData": "2017-04-18T11:41:14.4606538+02:00",
- "url": "sample string 4",
- "showImageOnInternet": true,
- "extension": "sample string 6"
- }
- },
- {
- "livingSpace": 1.1,
- "rooms": 1.1,
- "price": 2.1,
- "id": "sample string 3",
- "status": {
- "id": "sample string 1",
- "name": "sample string 2"
- },
- "customerId": "sample string 4",
- "areaName": "sample string 5",
- "dateChanged": "2017-04-18T11:41:14.4606538+02:00",
- "streetAddress": "sample string 6",
- "coordinate": {
- "longitud": 1.1,
- "latitud": 2.1
- },
- "shortSaleDescription": "sample string 7",
- "viewingsList": [
- {
- "startTime": "2017-04-18T11:41:14.4606538+02:00",
- "endTime": "2017-04-18T11:41:14.4606538+02:00"
- },
- {
- "startTime": "2017-04-18T11:41:14.4606538+02:00",
- "endTime": "2017-04-18T11:41:14.4606538+02:00"
- }
- ],
- "bidding": true,
- "mainImage": {
- "imageId": "sample string 1",
- "dateChanged": "2017-04-18T11:41:14.4606538+02:00",
- "dateChangedImageData": "2017-04-18T11:41:14.4606538+02:00",
- "url": "sample string 4",
- "showImageOnInternet": true,
- "extension": "sample string 6"
- }
- }
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement