phpでpost json ファイルかす
php po.php http://yahoo.cojp { test4 :¥[{ test5 : ccc test6 : ddd }¥]} o1.log
function http_post ($url $data $outputfile)
<?php
// URLを指定
$url = $argv[1];
$data = $argv[2];
$outputfile = $argv[3];
// POST用関数
function http_post($url $data $outputfile)
{
$data_url = http_build_query ($data);
$data_len = strlen ($data_url);
return array (
content => file_get_contents (
$url
false
stream_context_create (
array ( http =>
array (
method => POST
header => Content-Type: application/x-www-form-urlencoded¥r¥nContent-Length: $data_len¥r¥n
content =>$data_url)
)
)
)
headers => $http_response_header
);
}
// 送信
$result = http_post($url $data $outputfile);
$fp = @fopen($outputfile w );
ob_start();
print_r($result);
$buffer = ob_get_contents();
ob_end_clean();
fputs($fp $buffer);
fclose($fp);
?>