I've got an application that is based on PHP 7.0 and that uses the API to collaborate.
The basic API connections work, I can read directories and create folders.
For example folder creation:
<?PHP$accesstoken='123';$xml='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><folder><name>Test HH2</name><description>Via API</description><accessInherited>1</accessInherited></folder>';$ch = curl_init();curl_setopt($ch, CURLOPT_URL,"instancename.highq.com/.../folders curl_setopt($ch, CURLOPT_PROXY, "456");curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/xml; charset=utf-8','Authorization:Bearer '.$accesstoken));curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS,$xml);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);$server_output = curl_exec($ch);curl_close ($ch);echo $server_output;?>
But I can not manage the file upload.
I follow the API instruction here:
collaborate.highq.com/.../wikiHome.action
My code looks like this:
<?PHP$accesstoken='123';$file=file_get_contents('/path/testhh.txt');$fields = array('file' => $file, 'filename' => 'test2.txt');$ch = curl_init();curl_setopt($ch, CURLOPT_URL,"instancename.highq.com/.../content curl_setopt($ch, CURLOPT_PROXY, "456");curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:multipart/form-data','Authorization:Bearer '.$accesstoken));curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS , $fields);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);$server_output = curl_exec($ch);curl_close ($ch);echo($server_output);?>
The file “test2.txt” mentioned here exists, so that’s not the problem.
But the resulting error is:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><error><link>instancename.highq.com/.../ref><summary>Access denied</summary></error>
Could someone help me here?
Thx, Helmut