Get data from app kintone via API

Dear All,

I am new to Kintone. I have a Kintone App with the following fields that I want to display on a PHP file: field_A, サービス内容, 一般料金(ルピア)【一覧】

My script:

<?php

$query =$_POST['query'];  
$subdomain = "INSERT_SUBDOMAIN_HERE"; // subdomain  
$token = "INSERT_API_TOKEN_HERE";  
$appId = "INSERT_APP_ID_HERE"; // App ID of product app

$url="https://INSERT_SUBDOMAIN_HERE.cybozu.com/k/v1/record.json?app=18&id=1";

$subdomain = "INSERT_SUBDOMAIN_HERE"; // subdomain  
// Set HTTP header to send to server  
$options = array (  
'http' => array (  
'method' => 'GET',  
'header' => "X-Cybozu-API-Token:". $token. "r "  
)  
);  
$buildQuery = http_build_query (array ("app" => $appId, "query" => $query), "", "&");  
// create context  
$context = stream_context_create ($options);  
// Connect to the server and get data  
//$contents = file_get_contents ('https: //'.$subdomain.'.cybozu.com/k/v1/records.json?'.$buildQuery, FALSE, $context);  
$contents = file_get_contents( 'https://'.$subdomain.'.cybozu.com/k/v1/records.json?'.htmlspecialchars_decode($buildQuery), FALSE, $context );

$data = json_decode ($contents, true);  
echo json_encode ($data ["records"]);  
echo $data;  
?>

Hello Rika,

I am not too familiar with PHP but once I proceeded as is, the 1st parameter of file_get_contents URLs query part became null.

My guess is that the URL is not set up correctly and also, I was not sure what type of errors were coming up.

By executing the process below, you can obtain the value of the record.


define(“API_TOKEN”, “*****”);

define(“SUB_DOMAIN”, “****”);

define(“APP_NO”, “100”);

define(“QUERY”, “limit 1”);

//set up an HTTP header transmitting a server

$options = array(

‘http’=>array(

‘method’=>‘GET’,

‘header’=> “X-Cybozu-API-Token:”. API_TOKEN ."\r"

)

);

//generate the context

$context = stream_context_create( $options );

//connected to the server receive data

$contents = file_get_contents( ‘https://’. SUB_DOMAIN .’.cybozu.com/k/v1/records.json?app=’. APP_NO .’&query=’. urlencode(QUERY), FALSE, $context );

echo $contents;


You can also process the PHP from the page below:

https://paiza.io/ja/projects/new

Please tell us know what type of errors you are getting and where it is happening so we can assist you further.