REST API‎ > ‎Media Management‎ > ‎

Blast

This method causes the specified networkid to be called and played a previously-recorded audio clip.

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

Path parameter: 
  • mediaid  A list of one or more media ids, separated by a "-" (minus sign/hyphen).  The media files will be played in the order that they appear in this list.
Form parameters:
  • networkid  The networkid to call.
  • appkey  The application key associated with both the networkid and the application.
  • action  The action to perform - ("blast").
  • greetingid Optional.  The media ID of a pre-recorded greeting, to be played when the phone is answered.  If this parameter is not supplied, the default greeting will be used.
Returns:
  • ACCEPTED(202) - The "blast" request has been accepted.
  • BAD_REQUEST(400) - Missing parameter(s).
  • NOT_FOUND(404) - The application key is invalid or the application is not associated with the networkid.
  • BAD_GATEWAY(502) - Unable to initiate phone call at this time.
Response format: JSON

Example using curl

curl -d "appkey=1f1bbca5-b71f-4938-97b6-59fed80623bc&action=blast&networkid=eta" "https://api.telesocial.com/api/rest/media/6e6a151be31b467f87225b18b0f36f00"

Response body:

{"MediaResponse":{"message":"6e6a151be31b467f87225b18b0f36f00","status":202,"downloadUrl":"","fileSize":0,"mediaId":"","uri":""}}



PHP Example

 public function playMessage($mediaID, $networkID, $greetingID = false)
    {
        $query = new telesocialQuery('media', $mediaID);
        $query->addApiKey();
        $query->add('action', 'blast');
        $query->add('networkid', $networkID);

        if ($greetingID)
        {
            $query->add('greetingid', $greetingID);
        }

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

        return false;
    }

Another PHP Example (why not?)

 public function blastCall($networkId, $mediaId) {
        // If $networkId or $mediaId is blank - return false
        if (empty($networkId) || empty($mediaId)) {
            return false;
        }
        // Build query
        $query  = 'appkey=' . $this->APIKey;
        $query .= '&action=blast&networkid=' . urlencode($networkId);
        // Send query to server
        $return = $this->sendQuery(
        'api/rest/media/' . urlencode($mediaId),
        $query
        );
        // Parse reply
        $return = $this->checkResponse($return, 'MediaResponse');
        // Now we need to understand that to do and return with this result
        switch ($return['status']) {
            case 202:
                return $return;
            case 400:
                throw new TelesocialApiException(
                    empty($return['message'])
                        ? 'Missing parameter(s)'
                        : $return['message'],
                    102);
            case 500:
                return false;
        }
        return false;
    }



RUBY Example (not too shabby)

def blast(network_id, media_id, greeting_id = nil)
      response = post("/api/rest/media/#{media_id}",:body => {:networkid => network_id, :appkey => @api_key, :action => "blast", :greetingid => greeting_id})

      case response.status
      when 200,201,202
      when 400
        raise Telesocial::BadRequest.new("Missing parameter(s).", response)
      when 404
        raise Telesocial::NotFound.new("The application key is invalid or the application is not associated with the networkid.", response)
      when 502
        raise Telesocial::BadGateway.new("Unable to initiate phone call at this time.", response)
      end

      response
    end


.NET / C# Using the SDK Client (cheating)

 public Media Blast(Network network, Media greeting = null) {
            if (network == null) throw new ArgumentNullException("network");

            var r = Client.TelesocialClient.Blast(ID, network.ID, greeting != null ? greeting.ID : null);
            return this;
        }