@dhruvdutt/

Appbase.io - PHP - get

PHP (Legacy)

GET operations (or Read) for fetching data and queries

fork
loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.5849082116673245","path":"main.php","file":{"path":"main.php","content":{"asEncoding":{"base64":"JGN1cmwgPSBjdXJsX2luaXQoKTsKCmN1cmxfc2V0b3B0X2FycmF5KCRjdXJsLCBhcnJheSgKICBDVVJMT1BUX1VSTCA9PiAiaHR0cHM6Ly9zY2Fsci5hcGkuYXBwYmFzZS5pby9ob3VzaW5nLWRlbW8vbGlzdGluZy9IMSIsCiAgQ1VSTE9QVF9SRVRVUk5UUkFOU0ZFUiA9PiB0cnVlLAogIENVUkxPUFRfRU5DT0RJTkcgPT4gIiIsCiAgQ1VSTE9QVF9NQVhSRURJUlMgPT4gMTAsCiAgQ1VSTE9QVF9USU1FT1VUID0+IDMwLAogIENVUkxPUFRfSFRUUF9WRVJTSU9OID0+IENVUkxfSFRUUF9WRVJTSU9OXzFfMSwKICBDVVJMT1BUX0NVU1RPTVJFUVVFU1QgPT4gIkdFVCIsCiAgQ1VSTE9QVF9IVFRQSEVBREVSID0+IGFycmF5KAogICAgIkF1dGhvcml6YXRpb246IEJhc2ljIFdXNURaMVozYjNwV09tVTVaV00xWTJJd0xUVTRaRGd0TkdKaU1DMWlZV1JqTFdGallXWTNNalkyTmpGbU1RPT0iLAogICAgIkNvbnRlbnQtVHlwZTogYXBwbGljYXRpb24vanNvbiIKICApLAopKTsKCiRyZXNwb25zZSA9IGN1cmxfZXhlYygkY3VybCk7CiRlcnIgPSBjdXJsX2Vycm9yKCRjdXJsKTsKCmN1cmxfY2xvc2UoJGN1cmwpOwoKaWYgKCRlcnIpIHsKICBlY2hvICJjVVJMIEVycm9yICM6IiAuICRlcnI7Cn0gZWxzZSB7CiAgJGpzb24gPSBqc29uX2RlY29kZSgkcmVzcG9uc2UsIHRydWUpOwogIHByaW50X3IoIkBnZXQgc3VjY2VzczogIik7CiAgcHJpbnRfcigkanNvblsiX3NvdXJjZSJdKTsKfQ=="},"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
$curl = curl_init();

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 => "GET",
  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("@get success: ");
  print_r($json["_source"]);
}
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