可能重复:
通过 Rest 服务器登录 Drupal
我一直在使用此代码获取包含发布数据的文件内容,但收到错误
Warning: file_get_contents(http://50.116.19.49/rest/user/login.json): failed to open
stream: HTTP request failed! HTTP/1.0 406 Not Acceptable: Unsupported request content type
application/x-www-form-urlencoded in C:\xampp\htdocs\post.php on line 20
我的代码是
<?php
$postdata = http_build_query(
array(
'var1' => 'myuser',
'var2' => 'pwd'
)
);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$result = file_get_contents('http://50.116.19.49/rest/user/login.json', false,
$context);
?>
任何人都可以在此提前提供帮助。