1.7.5 APIs calls with cURL

Hi

I’m trying to use the CMS functions via 3rdparty apps, to do so I’m using php libcURL.

The problem is that when I’m calling the CMS functions I return empty responses, cURL logs no errors.

As I’m new to developpement I assume the error is from my code but even walking through the community posts but I didn’t found any clue to resolve my issue.

Here is a part of my calls:

function libraryupload(){
    $url = 'http://localhost:8080/xibo/3rdparty/cmsapi/xibo-functions.php';
    $curl = curl_init();
    curl_setopt($curl,CURLOPT_URL,$url.'?'."action=LibraryMediaFileUpload");
    curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($curl, CURLOPT_USERAGENT , "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
    curl_setopt($curl, CURLOPT_CONNECTTIMEOUT , 7);
    curl_setopt($curl,CURLOPT_FAILONERROR,true);
    curl_setopt($curl, CURLOPT_HEADER, true);

    $curl_response = curl_exec($curl);
    $info = curl_getinfo($curl);

    if (!curl_errno($curl))
    {
         $data = json_decode($curl_response, true);
         return $data;
    }
   else
   {
       printf("cUrl error (#%d): %s<br>\n", curl_errno($curl),
       htmlspecialchars(curl_error($curl)));
   }
   curl_close($curl);
   }

“xibo-functions.php” is just “index.php” in Oauth2 folder renamed.

I’ve also edited the function called:

function LibraryMediaFileUpload() {

    // Get the test file
    $file = file_get_contents('../imagen/editImg/agenda2016.jpg');
    $payload = base64_encode($file);
    
    $params = array(
        'service' => 'rest',
        'method' => 'LibraryMediaFileUpload',
        'response' => RESPONSE,
        'fileId' => NULL,
        'checksum' => md5($payload),
       'payload' => $payload
     );

     callService($params, true);

     $params0 = array(
        'service' => 'rest',
        'method' => 'LibraryMediaAdd',
        'response' => RESPONSE,
        'fileId' => NULL,
        'type' => 'image',
        'name' => 'Test image',
        'duration' => '15',
        'fileName' => '../imagen/editImg/agenda2016.jpg'
    );

   callService($params0, true);

}

A variant with verbose shows:

Verbose information:

  • Hostname was found in DNS cache
  • Trying ::1…
  • Connected to localhost (::1) port 8080 (#9)

GET /xibo/3rdparty/cmsapi/xibo-functions.php?action=LibraryMediaFileUpload HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)
Host: localhost:8080
Accept: /

< HTTP/1.1 200 OK
< Date: Wed, 30 Nov 2016 15:54:19 GMT

  • Server Apache/2.4.9 (Win64) PHP/5.5.12 is not blacklisted
    < Server: Apache/2.4.9 (Win64) PHP/5.5.12
    < X-Powered-By: PHP/5.5.12
    < Content-Length: 3132
    < Content-Type: text/html
    <
  • Connection #9 to host localhost left intact