REST API‎ > ‎Media Management‎ > ‎

Create Media

This method returns a Media ID that can be used with subsequent method calls that accept mediaid parameters.

Method: POST
URI: /api/rest/media

Form parameters:
  • appkey  The application key to associate with the Media ID.
Returns:
  • CREATED(201)  The Media ID was successfully created.
  • BAD_REQUEST(400)  Missing parameter(s).
  • NOT_FOUND(404)  The application key is invalid.
Response format: JSON

Example using curl

curl -d "appkey=1f1bbc2a5-b71f-4938-97b6-59fed803623bc" https://api.telesocial.com/api/rest/media

Response body:

{"MediaResponse":"message":"","status":201,"downloadUrl":"","fileSize":0,"mediaId":"6e6a151be31b467f87225b18b0f36f00","uri":"\/api\/rest\/media\/6e6a151be31b467f87225b18b0f36f00"}}


PHP Examples

In the example code below a mediaID is generated and fed to the "Record" function...


 public function createMedia($networkID, $greetingID = '380b6123ae9a65948a2988667b35f0ae71d')
    {
        $query = new telesocialQuery('media');
        $query->addApiKey();

        if ($query->make() && $query->response['status'] == 201)
        {
            //Getting media ID
            $mediaID = $query->response['mediaId'];

            //Recording
            $query = new telesocialQuery('media', $mediaID);
            $query->addApiKey();
            $query->add('networkid', $networkID);
            $query->add('action', 'record');
            if ($greetingID)
            {
                $query->add('greetingid', $greetingID);
            }

            if ($query->make() && $query->response['status'] == 202)
            {
                return $mediaID;
            }
        }

        return false;
    }