Advertisement
Guest User

Untitled

a guest
Apr 18th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ALL);
  3.  
  4. $url = 'url';
  5.  
  6. $username = 'xxx';
  7. $password = 'xxx';
  8.  
  9.  
  10. $ch = curl_init();
  11. curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
  12. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  13. curl_setopt($ch, CURLOPT_URL, $url);
  14. $data = "{
  15. "customerId":"A1234",
  16. "status": {
  17. "id": "2HIII41T24FNHOU2",
  18. "name": "Till salu"
  19. },
  20. "typeOfDate":0}";
  21. curl_setopt($ch, CURLOPT_POST, true);
  22.  
  23. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  24. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  25. 'Content-Type: application/json',
  26. 'Content-Length: ' . strlen($data)
  27. ));
  28.  
  29. $result = curl_exec($ch);
  30.  
  31. if (curl_errno($ch)) {
  32. die(curl_getinfo($ch));
  33. }
  34.  
  35. $info = curl_getinfo($ch);
  36.  
  37.  
  38. curl_close($ch);
  39.  
  40. $http_code = $info["http_code"];
  41.  
  42. if ($http_code == 401) {
  43. // Username password wrong
  44. }
  45. if ($http_code == 403) {
  46.  
  47. }
  48. if ($http_code == 500) {
  49.  
  50. }
  51. if ($http_code == 400) {
  52. $json = json_decode($result, true);
  53.  
  54. }
  55. print_r($result);
  56.  
  57. ?>
  58.  
  59. [
  60. {
  61. "customerId": "sample string 1",
  62. "houses": [
  63. {
  64. "livingSpace": 1.1,
  65. "rooms": 1.1,
  66. "price": 2.1,
  67. "id": "sample string 3",
  68. "status": {
  69. "id": "sample string 1",
  70. "name": "sample string 2"
  71. },
  72. "customerId": "sample string 4",
  73. "areaName": "sample string 5",
  74. "dateChanged": "2017-04-18T11:41:14.4606538+02:00",
  75. "streetAddress": "sample string 6",
  76. "coordinate": {
  77. "longitud": 1.1,
  78. "latitud": 2.1
  79. },
  80. "shortSaleDescription": "sample string 7",
  81. "viewingsList": [
  82. {
  83. "startTime": "2017-04-18T11:41:14.4606538+02:00",
  84. "endTime": "2017-04-18T11:41:14.4606538+02:00"
  85. },
  86. {
  87. "startTime": "2017-04-18T11:41:14.4606538+02:00",
  88. "endTime": "2017-04-18T11:41:14.4606538+02:00"
  89. }
  90. ],
  91. "bidding": true,
  92. "mainImage": {
  93. "imageId": "sample string 1",
  94. "dateChanged": "2017-04-18T11:41:14.4606538+02:00",
  95. "dateChangedImageData": "2017-04-18T11:41:14.4606538+02:00",
  96. "url": "sample string 4",
  97. "showImageOnInternet": true,
  98. "extension": "sample string 6"
  99. }
  100. },
  101. {
  102. "livingSpace": 1.1,
  103. "rooms": 1.1,
  104. "price": 2.1,
  105. "id": "sample string 3",
  106. "status": {
  107. "id": "sample string 1",
  108. "name": "sample string 2"
  109. },
  110. "customerId": "sample string 4",
  111. "areaName": "sample string 5",
  112. "dateChanged": "2017-04-18T11:41:14.4606538+02:00",
  113. "streetAddress": "sample string 6",
  114. "coordinate": {
  115. "longitud": 1.1,
  116. "latitud": 2.1
  117. },
  118. "shortSaleDescription": "sample string 7",
  119. "viewingsList": [
  120. {
  121. "startTime": "2017-04-18T11:41:14.4606538+02:00",
  122. "endTime": "2017-04-18T11:41:14.4606538+02:00"
  123. },
  124. {
  125. "startTime": "2017-04-18T11:41:14.4606538+02:00",
  126. "endTime": "2017-04-18T11:41:14.4606538+02:00"
  127. }
  128. ],
  129. "bidding": true,
  130. "mainImage": {
  131. "imageId": "sample string 1",
  132. "dateChanged": "2017-04-18T11:41:14.4606538+02:00",
  133. "dateChangedImageData": "2017-04-18T11:41:14.4606538+02:00",
  134. "url": "sample string 4",
  135. "showImageOnInternet": true,
  136. "extension": "sample string 6"
  137. }
  138. }
  139. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement