Niklas,
Would be easier for us if you share some code that does not require
non-standard PHP modules or those that are not required for running and
developing ownCloud.
Anyways, the following code works with cURL
<?php
$username = 'lukas';
$password = 'lukas';
$ch = curl_init('http://localhost/master/ocs/v1.php/cloud/groups');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
$output = curl_exec($ch);
curl_close($ch);
echo $output;
Best
Lukas
On Sun, Oct 18, 2015 at 3:34 PM Niklas Frings <[email protected]> wrote:
> Hello everyone,
> I have a problem according to the User Provisioning API.,
> After asking in the forum for some help, I got the information that I
> should send this via this mailinglist.
> I can access the OC-Commands only by my Browser and not by my PHP-Scripts.
> So e.g., the request
> http://user:[email protected]/owncloud/ocs/v1.php/cloud/groups
> works fine if I use Firefox on my Windows-Client (but only if I am not
> logged in owncloud with any account). If I want to access this via lynx on
> my server, I have to authenticate myself a second time, but than it works
> without any problems. But if I want to send the request via
> http_get-function or the HttpRequest-Class, I get an 401-Error in the
> HTTP-Header, so I am not authenticated by Owncloud. The HTTP-Body includes
> the following:
>
> <ocs>
> <meta>
> <status>failure</status>
> <statuscode>997</statuscode>
> <message>Unauthorised</message>
> </meta>
> <data/>
> </ocs>
>
>
> Because of this, I think that there is any failure in the
> OwnCloud-Configuration, but even after studying the Adminsitrators and
> Developers-Manual and asking Google, I cannot find anythink which could
> help me.
> I am using OwnCloud 8.1.3 and php 5.5.9 on an apache2-ubuntu14.04-server.
>
> The PHP-Codes I have trested this with are
> 1.
> $response = http_get(
> "http://usr:[email protected]/owncloud/ocs/v1.php/cloud/groups"
> <http://usr:[email protected]/owncloud/ocs/v1.php/cloud/groups>,
> array(httpauth=>"url:pwd"), $info);
>
> 2.
>
> $http = new HttpRequest('
> http://usr:[email protected]/owncloud/ocs/v1.php/cloud/groups',
> HttpRequest::METH_GET);
> $http->setOptions(array(httpauth=>"usr:pwd"));
> $http->send();
> $response = $http->getResponseBody();
>
> I have tried both with and without th httpauth-Option.
>
> So, I hope that there is anybody here who can help me fixing the Problem.
> Greeting
> Niklas
> _______________________________________________
> Devel mailing list
> [email protected]
> http://mailman.owncloud.org/mailman/listinfo/devel
>
_______________________________________________
Devel mailing list
[email protected]
http://mailman.owncloud.org/mailman/listinfo/devel