Coder Social home page Coder Social logo

brightcove / php-api-wrapper Goto Github PK

View Code? Open in Web Editor NEW
25.0 40.0 33.0 207 KB

This project provides a starting point for integrating the Brightcove CMS API into your application. It provides simple ways to interact with the API, as well as a long list of helper functions.

PHP 100.00%

php-api-wrapper's Introduction

PHP Wrapper for the Brightcove API

Installation notes

This library requires PHP 7.1 or newer with a CURL extension. You have to run composer install before using the library.

# apt-get install php5 php5-curl curl

PHP-API-Wrapper$ curl -sS https://getcomposer.org/installer | php

PHP-API-Wrapper$ php composer.phar install

Testing notes

Running the tests requires a config.json file. There's a sample file included in the repository.

A reverse SSH tunnel is needed for the DI API test. When you set it up, make sure that the port is open on the remote server too.

Example script:

#!/bin/sh

ssh -nNT -R 8888::8888 example.com &>ssh_tunnel_logfile.txt &
PID=$!

cleanup () {
    kill ${PID}
    cat ssh_tunnel_logfile.txt
    rm ssh_tunnel_logfile.txt
}

handle_error () {
    cleanup
    exit 1
}

./vendor/bin/phpunit

cleanup

php-api-wrapper's People

Contributors

chibani avatar dawehner avatar janmashat avatar jspizziri avatar konczgabor avatar lekob avatar simesy avatar tamasd avatar ycecube avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-api-wrapper's Issues

Video\Image doesn't expose HTTPS url

It seems the API has evolved and now includes a "sources" attribute which includes a two item array with the http:// and https:// URLs. This attribute is the only way to get the HTTPS version, however it isn't exposed in this library.

{
    "poster" : {
      "asset_id" : "",
      "remote" : false,
      "src" : "http://brightcove.vo.llnwd.net/e1/pd/…/…-vs.jpg?pubId=…&videoId=…",
      "sources" : [ {
        "src" : "http://brightcove.vo.llnwd.net/e1/pd/…-vs.jpg?pubId=…&videoId=…",
        "height" : 360,
        "width" : 641
      }, {
        "src" : "https://brightcove.hs.llnwd.net/e1/pd/…/…-vs.jpg?pubId=…&videoId=…",
        "height" : 360,
        "width" : 641
      } ]
    }
}

Organization

Also, I would suggest organizing the project a bit differently.

For instance put all the test classes in a Test folder, and use namespaces and so on. Perhaps putt all "brightcove_" files in a root Brightcove folder and use that as the root namespace. And only put one "class/interface" per file and rename the files to represent the classes they actually contain.

What is the likelyhood that something like this will be done?

How to get FLV URL with the new API?

With the old API, it was possible to get the FLV URL like:

$bc = new BCMAPI(
	    	'xxx', 'xxx'
	    );
		$searchParams = array(
	        'video_id' => $id,
	        'media_delivery' => 'HTTP',
	        'video_fields' => 'FLVURL'
	    );
		$cbf = $bc->find('videobyid', $searchParams);
		$flvurl = $cbf->{'FLVURL'};

With the new API I tried:

                    $CLIENT_ID = 'xxx';
                    $CLIENT_SECRET = 'xxx';
                    $ACCOUNT = 'xxx';

                        $CLIENT = \Brightcove\API\Client::authorize($CLIENT_ID, $CLIENT_SECRET);
                        $CMS = new \Brightcove\API\CMS($CLIENT, $ACCOUNT);

                        $cms_video = $CMS->getVideo($id);
                        var_dump($cms_video->link);

But the link attribute is always NULL.
Any help is greatly appreciated.

PM::listPlayers() returns status code 401

Using valid "read" API credentials, in the context of a CMS, we always get an "Invalid status code: 401".

"Could not authorize the requested video cloud operation with provided token"

Getting a list of videos and video fields works fine.

I couldn't find any player commands in the API docs. Could it be this command is no longer valid?

Issue with Client connection

Hi Tamsad,

I'm integrating
https://www.drupal.org/project/brightcove
in one of my drupal project. Setting up the module requires this library to be installed
https://github.com/brightcove/PHP-API-Wrapper/

I integrated this almost a month back. It was all working fine. We were able to connect to the client and communicate with Brightcove studio.

Suddenly from last two days it has stopped working and error which we get is:

Brightcove\API\Exception\APIException: Invalid status code: expected 200-299, got 0. in Brightcove\API\Client->request() (line 274 of /var/www/drupal-7.38/sites/all/libraries/PHP-API-Wrapper/lib/Brightcove/API/Client.php).

Thereafter, I tried with new release of the library and today installed
https://github.com/brightcove/PHP-API-Wrapper/
allover again. But no luck.

Can you please suggest what could be the issue.

Brightcove upload issue

Hi,

I'm using 0.8 version of this library and using Drupal module 7.x-6.4. And using aws s3 as middle layer for temporary storage instead of \tmp directory locally. Sometimes, randomly it's happening that video gets uploaded in s3 but doesn't get uploaded to brightcove studio. And sometimes upload happens flawlessly. When I debugged the code, I found that upload takes place in the function "function _brightcove_upload_form_callback" of brightcove.module and within this function it calls "brightcove_upload_and_ingest" function, which internally calls to functions:

_brightcove_create_classes

and

$video = $cms->createVideo($video);
$request = \Brightcove\API\Request\IngestRequest::createRequest($url, $profile);

when upload doesn't happen, it just returns [id:].

Can you please suggest why this can happen. It's a random issue I'm facing. Please suggest.

listVideos combine search giving empty result

Hi,
Im searching with following conditions,
In my account have the video name as "welcome to cloud". and tagged as "manager" between dates.
But both conditions are returning empty value for listVideo api call. but we have value for both conditions.

  1. +name:welcome+updated_at:2015-06-27T00:00:00.000Z..2015-06-30T00:00:00.000Z
  2. +tags:manager+updated_at:2015-06-27T00:00:00.000Z..2015-06-30T00:00:00.000Z

Please help me to fix this.

Error 400

Hi,

I am receiving a 400 response code. I've ensured the API application has all permissions enabled. Is there documentation for the error codes? I've been unable to find it.

Brightcove\API\Exception\APIException: Invalid status code: expected 200-299, got 400. in Brightcove\API\Client->request() (line 321 of /sites/all/libraries/PHP-API-Wrapper/lib/Brightcove/API/Client.php).

Playback API

Is there any intention of adding support for making Playback API requests?

It seems like an unexpected omission.

Auth Error

I'm trying to call listVideos() but I keep getting the error.

Error
Fatal error: Using $this when not in object context in /Users/*/*/Brightcove/Assetlist/lib/Brightcove/API/CMS.php on line 18

Line 18
return $this->client->request($method, 'cms', $this->account, $endpoint, $result, $is_array, $post);

I presume this is happening because of account and client not being assigned in API.php

Unauthorized message

When im trying to ingest the video, Im getting the following error...
Invalid status code: expected 200-299, got 401.
[{"error_code": "UNAUTHORIZED", "message": "Permission denied."}]
But im giving the valid credentials. what might be the issue?

When im running file as manual its running good, If i put automate(supervisord) job, its giving permission denied error.. Please help me to fix this...

Documentation or example code ?

I'm trying to convert some code we had that used the old BC-Mapi API library to use the new PHP-API-Wrapper API Library and am getting stuck on how this all works. Our existing code queried for new videos and changed videos at Brightcove and pulled down lists of those videos which we then used to create Drupal content that could drive things like listings of video content on certain pages on our sites.

Are there any examples or documentation available at all for this new PHP-API-Wrapper library ? The php-unit test code is of no help to me in understanding this and there has been really limited code cited in the four issues entered so far. Anything would be greatly appreciated. Thanks.

CMS API getVideoSource , Source class does not have the src param

We tried to get the video source renditions, So we used the getVideoSource function, Its giving all output except src values.
In the brightcove documentation there available "src" param in video source but we couldn't find in php api.
"src" : "http://brightcove.vo.llnwd.net/e1/uds/pd/1507807800001/1507807800001_2114524848001_Bird-Titmouse7.mp4",

http://docs.brightcove.com/en/video-cloud/cms-api/guides/retrieve-video-data.html#sourcesEndpoint

  1. How can we get "src" param using php api?
  2. Is there any alternative ways to get src in php api?

\Video->setCreatedAt(...) and setUpdatedAt(...), CMS API doesn't sense theme

I tried to modify the creation and update date of a video object but they are not sensed by the API, the dates are not modified by the call.

Sample code:

// $bc_video - brightcove video object (Brightcove\Item\Video\Video)
$dt = date('Y-m-d\TH:i:s\.\0\0\0\Z', 1544445000);
$bc_video->setCreatedAt($dt);
$bc_video->setUpdatedAt($dt);
try {
    $vidresult = $bccms->updateVideo($bc_video);
} catch (Exception $e) {
    die('Exception: ' .  $e->getMessage());
}
echo sprintf('Applied C: %s, U: %s', $vidresult->getCreatedAt(), $vidresult->getUpdatedAt()) . PHP_EOL;

API specs confirms that apparently

So there is no way to edit the creation and/or update date of a video?

setCustomField giving invalid field error

Im sending the following input for custom field

array(4) { ["field1"]=> string(6) "value1" ["field2"]=> string(6) "value2" ["field3"]=> string(6) "value3" ["field4"]=> string(6) "value4" }

but im getting following error when send the custom field.

Brightcove\API\Exception\APIException
Invalid status code: expected 200-299, got 422.
[ {
"error_code" : "VALIDATION_ERROR",
"message" : "custom_fields.field1: ILLEGAL_FIELD"
} ]

Please help me to fix this issue.

folder_id ILLEGAL_FIELD when trying to create video in a given folder

When trying to create a video with a certain folder id the API call fails with the following:

Invalid status code: expected 200-299, got 422.\n\n[ {\n  \"error_code\" : \"VALIDATION_ERROR\",\n  \"message\" : \"folder_id: ILLEGAL_FIELD\"\n} ]

The PHP code encountering the issue looks like this:

use Brightcove\API\Client;
use Brightcove\API\CMS;
use Brightcove\Object\Video\Video;

$brightcove_cms = new CMS(Client::authorize($client_id, $secret), $account_id);
$video = new Video();
$video->setName($filename);
// $folder_id is a 24 char alphanum id taken directly from the Brightcove interface
$video->setFolderId($folder_id);
$bc_video = $brightcove_cms->createVideo($video);

Error: Class 'Brightcove\API\Client' not found

Using a clean drupal 7.64 with php version 7.1.18. Installed Brightcove but the moment i add and save my api keys i get this error on submission:
Error: Class 'Brightcove\API\Client' not found in {closure}() (line 311 of /sites/all/modules/brightcove/brightcove.client.inc).

Using Brightcove Video Connect 7.x-6.5 using Brightcove API Wrapper 1.1.0(https://github.com/brightcove/PHP-API-Wrapper/releases/tag/1.1.0) and also tried 1.0(https://github.com/brightcove/PHP-API-Wrapper/releases/tag/1.0). Both versions gave me the same error.
library

Not sure if I'm missing a step?

Include Ingestion API and Profile object

Includes Ingestion API and Profile object in order to get available profiles from account.

I'd like to create a pull request for this changes but as this changes were made based on tag 1.1.0 I'm not sure how to create it.

This is the commit I'd like to create the PR.

Add drm_disabled in Video class

Hi,

I must update the drm_disabled property in the Video. Can you release a new release with the setter and getter for drm_disabled?

Thank you

Base Fields Error

I am getting the following error with version 0.6 when I try to upload a new video:
LogicException: Getting the base fields is not supported for entity type Brightcove API Client. in Drupal\Core\Entity\EntityFieldManager->buildBaseFieldDefinitions() (line 199 of /var/www/drupalvm/drupal/core/lib/Drupal/Core/Entity/EntityFieldManager.php).

I am running Drupal 8.1.1. I am running Brightcove Video Connect 8.x-1.0

Can't empty schedule after create

Trying to updateVideo with a previously filled schedule startsAt or endsAt value set to null doesn't do anything due to the way that the PHP Object -> JSON conversion works.
The patchJSON function in ObjectBase.php shouldn't be necessarily ignoring fields with null values as that may be a valid value for that field.

Allow list and count videos by folder on CMS

Nowadays users are only able to list and count videos by an account. Giving them the ability to filter by folders could help improving the process by syncing/importing only desired videos instead of all the existing videos in an account.

e.g. Using one Brightcove account for an organization with hundreds of small sites each with a hundred or so videos. The current solution means that each site with only a hundred or so videos must sync all videos in the organization (thousands) even though it only uses a hundred. Separating them by folder would help and, then, the Drupal module on each site could be configured to only sync specific folders instead of all videos.

More examples can be found here.

Composer

It would be great if you would complete the composer.json so that this package could be installed via composer.

PHP 7.2 compatibility

'object' is a soft reserved keyword as of PHP version 7.0 and a reserved keyword as of PHP version 7.2 and should not be used to name a class, interface or trait or as part of a namespace (T_NAMESPACE).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.