Open link in a new tab

Content

Expand project menu

API Authentication OpenProject 5.0.19(Mysql2)

Hi All,
I am attempting to use the API to return and post tasks to Open Project.
unfortunately I am unable to authenticate correctly. My session returns data accurately however when requested and following the API documentation I expected the same response in the following;

<?php

  1. An HTTP GET request example

$username= ‘a123456789b123456789c123456789d12345678e’;
$password=‘a123456789b123456789c123456789d12345678e’;
$URL=‘http://OPENPROJSERVER.ORG.AU/openproject/api/v3/projects/test’;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$URL);
curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

curl_setopt($ch, CURLOPT_USERPWD, $username.“:”.$password); //Authenticate

$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //get status code
$result=curl_exec ($ch);
print $result;
curl_close ($ch);
?>

Please advise what I am doing wrong ?
At this stage I’ve been at countless web forums and PHP examples which all do not work.

The following works successfully from a term, but not the code solution above…

curl get -u apikey:a123456789b123456789c123456789d12345678e http://OPENPROJSERVER.ORG.AU/openproject/api/v3/projects/test

Please help

Message actions

No soy muy diestro en ingles pero menos mal la programación se sobre entiende si importar la explicación en este caso :

Sintaxis (PHP)

class OpenProject {

public $error;
public $body;
public $header;
public $token;

public function ($url){
$ch = curl_init($url);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, ‘GET’);
curl_setopt($ch, CURLOPT_USERPWD, ‘apikey:’ . $thistoken); //Autenticación $this>token=
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($ch, CURLOPT_TIMEOUT, $this->_curl_timeout);
$response = curl_exec($ch);

$this->header = curl_getinfo($ch);
$error_no = curl_errno($ch);
$error = curl_error($ch);
curl_close($ch);

// Mostrar Información Retornada :
var_dump($this->body = $response);

}
}
Cualquier duda comentar.