api.friendlyrobot.fr/v2/nicknames/william/email/myemail@gmail.com/company/mycompany
{
"name": "william",
"gender": "M",
"nicknames": [
{
"nickname": "Bill",
"intimacy": "1"
},
{
"nickname": "Willy",
"intimacy": "2"
}
]
}
2022 update: I had to switch to v2 because of massive bot DDOS, so the API is no longer anonymous and requires you to fill your email address and company inside the query. Thanks for your understanding, and keep building great stuff 🤙
// Friendliness powered by www.FriendlyRobot.fr
$firstname = "william"; $email = "john@mycompany.com"; $company = "mycompany";
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_URL,
"http://api.friendlyrobot.fr/v2/nicknames/" . $firstname . "/email/" . $email . "/company/" . $company
);
$result = curl_exec($curl);
$nicknamesArray = json_decode($result, true);
// We pick a random nickname
if ($nicknamesArray != null) {
$rand = rand(0, (sizeof($nicknamesArray["nicknames"])-1) );
$nickname = $nicknamesArray["nicknames"][$rand]["nickname"];
}
else { $nickname = $firstName; }
// And we print a beautiful friendly message to our user :)
echo "Hey " . $nickname . ", how are you doing today ? :D ";
Of course, every first name hasn't a nickname right now. FriendlyRobot is an open API, enriched by the community. So feel free to propose new nicknames :)
api.friendlyrobot.fr/v2/propose/bill/for/william