I want to add a new page node using drupal services and REST server.
$postdata = http_build_query(array(
'type' => 'page',
'title' => 'aaa',
'field_test[en][0][value]' => '<p>test</p>\n',
'field_test[en][0][format]' => 'filtered_html'
)
);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-Type: application/json'."\r\n".
'Cookie: ' . $sessid."\r\n",
'content' => $postdata
)
);
$context = stream_context_create($opts);
$contents = file_get_contents($main_url."node", false, $context);
echo json_encode($contents);
When I run above code I get an error:
Warning: file_get_contents(http://192.168.1.129:80/test/node)
[function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0
401 Unauthorized:
Missing required argument node in D:\xampp\htdocs\serv\server.php on line 61