【发布时间】:2013-03-08 01:47:33
【问题描述】:
我需要将这些标头传递到 $context 变量中,我尝试使用将值放入数组中,然后将其传递到 stream_context_create() 函数中,但我从 file_getcontents 函数中收到 http 警告
$prod_id = 4322;
$tnxRef = "RT45635276GHF76783AC";
$mackey = "ADECNH576748GH638NHJ7393MKDSFE73903673";
$agent = $_SERVER['HTTP_USER_AGENT'];
$hash = hash('SHA512', $prod_id.$txnRef.$mackey);
$headers = array(
'http'=>(
'method'=>'GET',
'header'=>'Content: type=application/json \r\n'.
'$agent \r\n'.
'$hash'
)
)
stream_context_create($headers)
$url_returns = file_get_contents("https://test_server.com/test_paydirect/api/v1/gettransaction.json?productid=$prod_id&transactionreference=$txnRef&amount=$amount", false, $context);
$json = json_decode($url_returns, true);
错误:
[function.file-get-contents]:打开流失败:HTTP 请求失败! HTTP/1.1 400 错误请求`
这就是我得到的错误,有人可以帮忙举一个明确的例子吗?
【问题讨论】:
-
OPS,the main source 不存在!
-
在重复链接中找不到页面...
标签: php json http-headers httpwebrequest file-get-contents