Table of content

MCN Technical Integration Guide

You are a multi-channel network (MCN) and want to integrate Dailymotion as part of your users and videos management system? Here is how to use our API to do so.

Getting started

In order to develop with Dailymotion APIs, you need to create an API key on your parent account:

  • Log in and navigate to http://www.dailymotion.com/settings/developer. If you do not have a parent account yet, please get in touch with your content manager. Your parent account will be used to keep all your users in the same place and allow you to further control them.
  • The API key name, description and image will be shown to the end user as your brand in the login window. The callback URL should be the endpoint you chose to handle the user data returned by Dailymotion after logging in.

Note: Your API Key needs to have a specific role (can-adopt-users), please contact your content manager to make sure this is the case.


Onboarding process

In order to be considered as part of your network, a user should be a child of your master parent account. There are two different scenarios when it comes to user management:

  • The user is already an approved Partner of your network and wants to increase his reach by syndicating his videos to Dailymotion.
  • The user is a Dailymotion Partner and wants to be part of your network. Your approval is required.

On Dailymotion’s side, there is no difference between those use-cases: both need an action from you to adopt the children on Dailymotion. Hence you need to handle the difference between them (approving a new Partner or automatically adopting an existing Partner) internally.

#### Dailymotion Connect {#onboarding-dailymotion-connect}

The first step in the process is to connect the user using Oauth 2.0 authentication protocol. The user will be prompted to accept relevant terms and conditions allowing you to take full control and responsibility on his/her Dailymotion account. You’ll then be given access to the user’s information and assets.

In order to implement the user authentication process, refer to the authentication section, especially the client profiles section that will help you to choose the appropriate grant type depending on your needs and architecture.

  • If you want the user to authenticate through our popup window, you’ll most likely be using the authorization code grant type.
  • If you control the (future) child account and hence have its credentials, you can use the password grant type.

We also do offer several SDKs that will enable you to integrate with our oauth2 server and our api (read more on our SDK page).

During this stage, you need to choose and specify the scopes (= extended permissions from the user) you need from the user. The API Reference lists all fields you can request and the scopes that are needed to access them. The minimum scopes for user management are the following ones:

  • email
  • userinfo
  • delegate_account_management (This scope is mandatory, it allows the user to give you the management rights of his/her account).
  • read_insights (This scope will enable you to access revenues data from the user).

Once the user has accepted the permissions, you can start requesting information about his/her account through the API. You should store both the user’s id and username as they will be useful in your transactions with the API. Please read below for more details on how to retrieve user stats.

User adoption/rejection

In order to make the following calls, you need to pass the access_token you’re retrieved for authentication (read how to on our dedicated section. If you’re using one of our SDKs, the access token will automatically be passed during the calls.

User adoption

Adoption is done on the user’s endpoint, by creating a parents connection between the user object and your parent account. You have to issue a POST request to the /me/parents/<PARENT_ID> endpoint, using the child access token. This is meant to prevent unwanted account adoptions.

To adopt users, you need a specific role in your api key. Please check with your content manager if you have this role before making any user adoption api call.

Curl
PHP
curl -X POST -H "Accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: OAuth XXXXXXXXXXXXXXXXXXXXX" --data "" https://api.dailymotion.com/me/parents/PARENT_ID
$api->post("/me/parents/".$parentAccount);

An email will be sent to the user to inform him of the change of status.

User rejection

User rejection from your network has to be done with your parent account’s access_token, so you keep total control on your children accounts rejection. To generate an access token for your own account, please refer to the authentication guide.

To reject users, you need a specific role in your api key. Please check with your content manager if you have this role before making any user rejection api call.

Curl
PHP
curl -X DELETE -H "Accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: OAuth XXXXXXXXXXXXXXXXXXXXX" --data "" https://api.dailymotion.com/me/children/THE_CHILD_ACCOUNT_TO_REMOVE
$api->delete("/me/children/".$childAccount);

An email will be sent to the user to inform him of the change of status.

User verification

If you ever need to check if a user is a child of your account:

  • With the user’s access_token
Curl
PHP
curl -X GET -H "Accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: OAuth XXXXXXXXXXXXXXXXXXXXX" --data "" https://api.dailymotion.com/me/parents/YOUR_PARENT_USER
$response = $api->get("/me/parents/".$parentAccount);
  • Without any access_token, the following call lists all of your children accounts
Curl
PHP
curl -X GET -H "Accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" --data "" https://api.dailymotion.com/user/YOUR_PARENT_USER/children
$response = $api->get("/user/".$parentAccount."/children");

Managing data of your children accounts

Using the API, you can programmatically read and write to fields that are owned by your children accounts.

  1. Generate an access token for the parent user. This token includes permissions to access private data from their child accounts.
  2. Perform the API calls to request the data. Read our data API reference for more information on the available fields.

There are two ways to request children accounts private data from the DM API:

  • Perform an API call per child account (on behalf of the child account)
Curl
PHP
curl -X GET \
       -H 'Authorization: Bearer ${ACCESS_TOKEN}' \
       'https://api.dailymotion.com/user/<child_user_id>?fields=username,revenues_video_total,revenues_website_total,revenues_claim_total'
$response = $api->get(
    '/user/'.$childaccount,
    array('fields' => array('id', 'username', 'revenues_video_total','revenues_website_total','revenues_claim_total'))
 );

the response will be on the following format:

{
    "username":"child one",
    "revenues_video_total":8420.50,
    "revenues_website_total":12350.20,
    "revenues_claim_total":513.09
}
  • Perform an API call at the parent account level for all their child accounts
Curl
PHP
curl -X GET \
       -H 'Authorization: Bearer ${ACCESS_TOKEN}' \
       'https://api.dailymotion.com/user/<parent_user_id>/children?fields=id,username,revenues_video_total,revenues_website_total'
$response = $api->get(
    '/user/'.$parentAccount . '/children',
    array('fields' => array('id', 'username', 'revenues_video_total','revenues_website_total','revenues_claim_total'))
);

the response will be on the following format:

{
    "page":1,
    "limit":10,
    "explicit":false,
    "total":3,
    "has_more":false,
    "list":[
        {
            "id":"x1",
            "username":"child one",
            "revenues_video_total":8420.50,
            "revenues_website_total":12350.20
        },
        {
            "id":"x2",
            "username":"child two",
            "revenues_video_total":4420.50,
            "revenues_website_total":10350.20
        },
        {
            "id":"x3",
            "username":"child three",
            "revenues_video_total":21420.50,
            "revenues_website_total":16350.20
        }  
    ]
}

You can upload videos on behalf of your children

curl --request POST \
     --header "Authorization: Bearer ${YOUR_ACCESS_TOKEN}" \
     --form 'url=<VIDEO_URL>' \
     --form 'title=My Upload' \
     --form 'channel=fun' \
     --form 'published=true' \
     "https://api.dailymotion.com/user/${YOUR_CHILDREN_ID}/videos"

For more information about video uploads, see this guide.


Content ingestion

Note: Please make sure you shared the details of your catalog with your content manager in order to be ready for massive content ingestion.

In order to syndicate all the videos from your user accounts to Dailymotion, you will need to implement several endpoints. The first and most important one will be the users directory, which will be used to let us know which users you want us to syndicate onto Dailymotion. In this user list, you will provide us with feeds (one for each user) that will be a standardized XML listing of the videos of this users you want to syndicate. Once everything is set up on your side, our automated tasks will crawl your endpoints and import the videos.

User list

The user list is the reference directory that will allow us to be aware of the users who want to have their content syndicated to Dailymotion. You will be responsible for maintaining and cleaning this list. It consists of an endpoint (preferably secured with some kind of authentication) serving a JSON file as below:

[{"id":"x34ps8i","feed_url":"http..."},
 {"id":"x974sc23","feed_url":"https..."},
 {"id":"x79djj3","feed_url":"https..."},
 ...
]

MRSS Feeds / Video list

As described above, every user in the list needs to have an associated video feed. You need to create an endpoint that will be responsible for providing those video feeds. Dailymotion’s standard for video feeds is MRSS. You can find everything on the MRSS specification here: http://www.dailymotion.com/dmrss#MRSSImporterSpecifications. Please follow this specification and keep the following points in mind:

  • You are responsible for cleaning up the MRSS video feeds from already imported videos, that is why it is highly recommend generating those feeds on the fly based on your videos metadata.
  • You need to make sure that you provide a “guid” for all the videos in the MRSS. The guid can be any internal id that you use to identify your own videos. If you do not provide this id, you will not be able to match newly created Dailymotion videos with your own.

Callbacks and catalog syncing

In the previous section, you learnt how to make Dailymotion aware of the videos you are willing to synchronize. The missing part is for you to know about the status of those imports. As this is an asynchronous process, the only way to do so is setting up a callback. You need to provide us with an endpoint on which we will POST the status of every video processing. The POST data will be a JSON file as below:

[{"timestamp": 1407770138078,
"type": "injector.item.ready",
"data": {"status": "ready",
             "user_id": "528399c594a6f6616c1df20c",
             "uid": "3725074091001",
             "remote_id": "x23bz3t",
             "feed_id": "533c2d9094739902e64ff000",
             "item_id": "53e8ddf99473991dcf92ce47"}
}]

The logic you need to implement on your side is:

  • Verify that the status is ready (if not, the injection has failed, please contact your contact manager with the full JSON response)
  • Map the uid (which is the ID you provided in section above) with the remote_id (which is the Dailymotion new video ID)
  • Remove the video from the MRSS video feed.

Note: When you are done creating your endpoints, please send their reference to your content manager, so we can set up the import process on our side. We need the following:

  • User list URL (only one)
  • Video MRSS URLs referenced in the user list (should be user-dependent)
  • Callback URL (only one)