SERVICE_FORBIDDEN error

5 replies [Last post]
Joined: 03/05/2010
Points: 14

Hey folks- I'm trying to update clip data programatically (title and tags) using the API (we're using the Kaltura hosted solution), and I'm consistently getting SERVICE_FORBIDDEN.

Here's my PHP code:

        $partnerUserID          = '31'; // this can be whatever you decide depending on your implementation
        $config           = new KalturaConfiguration(KALTURA_PARTNER_ID);
        $client           = new KalturaClient($config);
        $ks               = $client->session->start(KALTURA_PARTNER_WEB_SERVICE_ADMIN_SECRET, $partnerUserID, KalturaSessionType::ADMIN);
        //Set the generated KS as the default actions KS to use by the client library
        $client->setKs($ks);

        $u = "http://www.kaltura.com/api_v3/?service=baseentry&action=update";
        $data = array('id' => $id, "baseEntry:tags" => urlencode($tags), "baseEntry:title" => urlencode($title));

        $ch = curl_init($u);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
       
        curl_exec($ch);
        curl_close($ch);

The code is clearly firing, and if I remove the baseEntry object from the $data var, I get a different error that the required BaseEntry is missing.

I'm just not sure why I can't actually make the update. I've also tried it against the media object (which leads me to another question: what's the difference between media->update() and baseEntry->update()?)

Thanks!
-Rob

Joined: 07/19/2009
Points: 179

Hi Rob,

Why are you switching in the middle of the code from Kaltura client to curl?

Media is a super-set of base entry, you can go over the client and see which field are being added by MediaEntry over BaseEntry.

Ofer

Joined: 03/05/2010
Points: 14

Ofer- Good question. Probably because I'm not terribly familiar with the API calls, and since the docs indicated that it wants POST data to the URL, I just figured I'd CURL it. I had a feeling that wasn't the right way to go about doing it, but I just don't know how to do it using the client (I've only pulled data back thus far), and the API docs are super confusing.

Would you be able to point me in the right direction using the client?

Thanks!
-Rob

Joined: 03/05/2010
Points: 14

Ofer- Thanks for initially questioning my use of CURL. I went back and began digging deeper into the client class files and was able to make it work properly using the client.

Thanks!
-Rob

Joined: 07/19/2009
Points: 179

Glad I could help

Joined: 02/15/2011
Points: 0

Hi Rob,

Try to follow this example :

$config = new KalturaConfiguration($partnerId);
$config->serviceUrl = 'http://www.kaltura.com/';
$client = new KalturaClient($config);
$entryId = $id;
$client->setKs($ks);
$baseEntry = new KalturaBaseEntry();
$baseEntry->name = 'updated name';
$baseEntry->tags = 'updated tags';
$results = $client-> baseEntry ->update($entryId, $baseEntry);

Orly.