REST API‎ > ‎Media Management‎ > ‎

Remove Media

This method is used to request remove a media instance.

Method: POST
URI: /api/rest/media/{mediaid}

Path parameter:
  • mediaid  The ID of the media to be removed.
Form parameters:
  • appkey  The application key
  • action  The action to perform - ("remove")
Returns:
  • OK(200) - The media has been removed.
  • BAD_REQUEST(400) - Missing or invalid parameter(s).
  • UNAUTHORIZED(401) - The content associated with the media ID cannot be removed.
  • NOT_FOUND(404) - The media ID is invalid.
Response format: JSON
Example using curl

curl -d "appkey=1f1bbca5-b71f-4938-97b6-59fed80623bc&action=remove" https://api.telesocial.com/api/rest/media/7dd9a82f99644f36a974af070824d64a 

Response body:

{"MediaResponse":{"message":"480464892.mp3 removed","status":200,"downloadUrl":"","fileSize":0,"mediaId":"7dd9a82f99644f36a974af070824d64a","uri":""}}

PHP Example

 public function removeMedia($mediaId) {
        // Check if required parameter is empty
        if (empty($mediaId)) {
            throw new TelesocialApiException(
            'Missing or invalid parameter',
            102);
        }
        // Build query
        $query = 'appkey=' . $this->APIKey . '&action=remove';
        // Send query to server
        $return = $this->sendQuery(
        'api/rest/media/' . urlencode($mediaId),
        $query
        );
        // Parse reply
        $return = $this->checkResponse($return, 'MediaResponse');
        // Return value depending on status code
        switch ($return['status']) {
            case 200:
                return $return;
            case 404:
                return false;
            case 401:
                throw new TelesocialApiException(
                'The content associated with the media ID cannot be removed.',
                103
                );
            case 400:
                throw new TelesocialApiException(empty($return['message'])
                    ? 'Missing or invalid parameter(s).' : $return['message'],
                    102
                );
        }
        return false;
    }