@dhruvdutt/

Appbase.io - PHP - index

PHP (Legacy)

Insert any JSON object

fork
loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.04182254616122316","path":"main.php","file":{"path":"main.php","content":{"asEncoding":{"base64":"JGN1cmwgPSBjdXJsX2luaXQoKTsKCiRqc29uT2JqID0ganNvbl9lbmNvZGUoYXJyYXkoCiAgIm5hbWUiID0+ICJUaGUgV2hpdGUgSG91c2Fkc2UiLAogICJyb29tX3R5cGUiID0+ICJQcml2YXRlIHJvb20iLAogICJwcm9wZXJ0eV90eXBlIiA9PiAiVG93bmhvdXNlIiwKICAicHJpY2UiID0+IDEyNCwKICAiaGFzX2F2YWlsYWJpbGl0eSIgPT4gdHJ1ZSwKICAiYWNjb21tb2RhdGVzIiA9PiAyLAogICJiZWRyb29tcyIgPT4gMSwKICAiYmF0aHJvb21zIiA9PiAxLjUsCiAgImJlZHMiID0+IDEsCiAgImJlZF90eXBlIiA9PiAiUmVhbCBCZWQiLAogICJob3N0X2ltYWdlIiA9PiAiaHR0cHM6Ly9hMi5tdXNjYWNoZS5jb20vYWMvcGljdHVyZXMvN2MyOGExNTUtM2ViOC00MzhkLThmNTEtNDI2YjE5MWFiNzk1LmpwZz9pbnRlcnBvbGF0aW9uPWxhbmN6b3Mtbm9uZSZjcm9wPXc6dzsqLComY3JvcD1oOmg7KiwqJnJlc2l6ZT01MDoqJm91dHB1dC1mb3JtYXQ9anBnJm91dHB1dC1xdWFsaXR5PTcwIiwKICAiaG9zdF9uYW1lIiA9PiAiQWx5c29uIiwKICAiaW1hZ2UiID0+ICJodHRwczovL2EwLm11c2NhY2hlLmNvbS9pbS9waWN0dXJlcy82ODgzNzc1Mi85NmNhZTRkMV9vcmlnaW5hbC5qcGc/YWtpX3BvbGljeT1tZWRpdW0iLAogICJsaXN0aW5nX3VybCIgPT4gImh0dHBzOi8vd3d3LmFpcmJuYi5jb20vcm9vbXMvNTM2NDExOSIsCiAgImxvY2F0aW9uIiA9P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bmRleCBzdWNjZXNzOiAiKTsKICBwcmludF9yKCRqc29uKTsKfQ=="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
$curl = curl_init();

$jsonObj = json_encode(array(
  "name" => "The White Housadse",
  "room_type" => "Private room",
  "property_type" => "Townhouse",
  "price" => 124,
  "has_availability" => true,
  "accommodates" => 2,
  "bedrooms" => 1,
  "bathrooms" => 1.5,
  "beds" => 1,
  "bed_type" => "Real Bed",
  "host_image" => "https://a2.muscache.com/ac/pictures/7c28a155-3eb8-438d-8f51-426b191ab795.jpg?interpolation=lanczos-none&crop=w:w;*,*&crop=h:h;*,*&resize=50:*&output-format=jpg&output-quality=70",
  "host_name" => "Alyson",
  "image" => "https://a0.muscache.com/im/pictures/68837752/96cae4d1_original.jpg?aki_policy=medium",
  "listing_url" => "https://www.airbnb.com/rooms/5364119",
  "location" => array(
    "lat" => 47.53540733743967,
    "lon" => -122.27983057017123
  ),
  "date_from" => 20170426,
  "date_to" => 20170421
));

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://scalr.api.appbase.io/housing-demo/listing/H1",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PUT",
  CURLOPT_POSTFIELDS => $jsonObj,
  CURLOPT_HTTPHEADER => array(
    "Authorization: Basic WW5DZ1Z3b3pWOmU5ZWM1Y2IwLTU4ZDgtNGJiMC1iYWRjLWFjYWY3MjY2NjFmMQ==",
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  $json = json_decode($response, true);
  print_r("@index success: ");
  print_r($json);
}
PHP 7.0.8 (Legacy: use the following for new features: Command-line PHP: https://repl.it/languages/php_cli PHP Web Server: https://repl.it/languages/php7