Upload media file
You need your AfricasTalking username and APIKey for any request to our API. If you don't have an APIKey, you can generate one from your applications settings page.
The PHP code snippet below shows how you can upload a media file to Africas Talking servers using our API.
The code uses our PHP gateway class: AfricasTalkingGateway.php [ Download]
Also, please ensure that you have the php_curl module enabled. To enable it uncomment the line: ;extension=php_curl.dll in php.ini and restart apache
You can upload a media/audio file to our servers. This media file will be played when called upon by one of our voice functionalities. ie.
Functionality | Attribute | Description |
---|---|---|
Play | url | This contains the audio file you want played during a call. | y
Call queueing | holdMusic | This contains the audio file you want played when the user has been queued waiting to be dequeued. |
Dial | holdMusic | This contains the audio file you want played when a number has been dialed before it's picked. |
Variable Name | Location | Description |
---|---|---|
apikey | Header | Your API Key, which you can generate from your dashboard |
username | Body | Your Africa's Talking account username |
url | Body | The url of the file to upload. Don't forget to start with http:// |
You can check the HTTP Response Code to determine whether the request was successful. Any response code other than 201 (Created) indicates that the call was not initiated
Example using CURL clientcurl -H "Accept: application/xml" -H "Apikey:myAPIKey" -d "username=myUsername&url=http://myOnlineMediaFile.mp3" https://voice.africastalking.com/mediaUpload --insecure