You have to use basic authentication using the appropriate curl parameter.
Quoting the relevant part of the manual:
6.1 Basic Authentication
HTTP Authentication is the ability to tell the server your username and password so that it can verify that you're allowed to do the request you're doing. The Basic authentication used in HTTP (which is the type curl uses by default) is plain text based, which means it sends username and password only slightly obfuscated, but still fully readable by anyone that sniffs on the network between you and the remote server.
To tell curl to use a user and password for authentication:
curl --user name:password http://www.example.com
So, in a terminal, your command should start somewhat like this:
curl --user RPCusername:RPCpassword http://127.0.0.1:7777 …
And (as a bonus) in PHP, it would look like this:
<?php
$RPCusername = 'test';
$RPCpassword = 'abc';
$somefundedBTCaddress = '1FeexV6bAHb8ybZjqQMjJrcCrHGW9sb6uF';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $RPCusername.':'.$RPCpassword);
curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1:7777');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"id":"curltext","method":"getaddressbalance","params":{"address":"'.$somefundedBTCaddress.'"}}');
curl_setopt($ch, CURLOPT_POST, 1);
$headers = array();
$headers[] = "Content-Type: application/x-www-form-urlencoded";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch))
{
echo 'Error:'.curl_error($ch).PHP_EOL;
}
else
{
$result =json_decode($result,true);
echo($result['result']['confirmed'].PHP_EOL);
echo($result['result']['unconfirmed'].PHP_EOL);
}
curl_close ($ch);
exit();