は私が話して何のことをあなたのための一例作成したなどとして、まだその応答を使用カール機能が表示されない場合: -
1.My両方のファイル(php
コードファイルをと同じ作業directory.Checkでjson
文字列ファイル): - http://prntscr.com/apkbp9
2. json
文字列ファイルの内容は次のようになります -
[
{
"email" : "",
"Name" : "Ddd",
"contact2" : "",
"ontact1" : ""
},
{
"email" : "",
"Name" : "Ddd",
"contact2" : "",
"contact1" : ""
},
{
"email" : "",
"Name" : "Dddddr",
"contact2" : "",
"contact1" : ""
}
]
ここでチェックイン: - http://prntscr.com/apkbx0
3. php
コードファイルの内容: -
<?php
$inputJSON = file_get_contents('input.txt');
echo $inputJSON;
$data = json_decode($inputJSON, TRUE);
echo "<pre/>";print_r($data);
?>
ここでチェックイン: - 私のブラウザでhttp://prntscr.com/apkc6x
出力: - http://prntscr.com/apkcoi
あなたは次のようにCURL
を使用することができます以下: -
<?php
function url_get_contents ($Url) {
if (!function_exists('curl_init')){
die('CURL is not installed!');
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
$inputJSON = url_get_contents('php://input');
echo $inputJSON;
$data = json_decode($inputJSON, TRUE);
echo "<pre/>";print_r($data);
?>
複数の基準については
についてCURL
: - http://php.net/manual/en/book.curl.php
注: - の両方が動作しない場合は、その後、最初のあなたは、拡張子.txt
のファイルにあなたのjson
データを保存する必要があり、その後、あなただけの、上記の両方のコードを使用することができますそのテキストファイルのフルパスを入力します。神優雅に
'$ inputJSON'に値がありますか? – aldrin27
echo $ inputJSON;何も与えません。 var_dump($ inputJSON);返り値string(0) "" – Lydia
php://これは前に私に働いています。 – Lydia