There is all the relevant information present in broken form in the following links on owncloud related websites and from stackoverflow itself:
- User Provisioning Api - Owncloud
- PHP + curl, HTTP POST sample code
- Create user on ownCloud using Ajax Jquery
- User Provisioning - php Authentication error
I am trying to do something very simple :
- I have setup an owncloud server in my localhost,
- I have an html page that takes in string values of user name and password
I send the page request to be processed by the following php script.
<?php echo "Begun processing credentials , first it will be stored in local variables" . "<br/>"; // Loading into local variables $userName = $_POST['username']; $RRpassword = $_POST['password']; echo "Hello " . $userName . "<br/>"; echo "Your password is " . $RRpassword . "<br/>"; // Add data, to owncloud post array and then Send the http request for creating a new user $ownCloudPOSTArray = array('username' => $userName, 'password' => $RRpassword ); $url = 'http://localhost/owncloud/ocs/v1.php/cloud/users'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $ownCloudPOSTArray); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); echo "<br/>Created a new user in owncloud"; ?>
I get the output like:
Begun processing credentials , first it will be stored in local variables
Hello Frank
Your password is frankspassword
failure 997 Unauthorised
Created a new user in owncloud
I also tried to login to own cloud using following php script:
// Login As Admin
$ownAdminname = 'ownAdmin';
$ownAdminpassword = 'ownAdminPassword';
$ch = curl_init('http://localhost/owncloud');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$ownAdminname:$ownAdminpassword");
$output = curl_exec($ch);
curl_close($ch);
echo $output;
Even this one fails.
So in short it doesn't work. I am also unable to login via similar script to owncloud. What is the proper way to do this ? What settings am I missing ? Can someone help please ?