4 best APIs for our Laravel Apps
If you want to access readable news data from thousands of international news publishers, automate language detection lightning-fast, or just want to get more information about your users. Try these 4 APIs! They're FREE to use!
Languagelayer
Tap into a world of live news data feeds, discover trends & headlines, monitor brands and access breaking news events around the world.
Mediastack
Feed the latest and most popular news articles into your website, fully automated.
Access 7500 news sources worldwide, including some popular ones: CNN, ESPN, CBS, etc.
ipapi
Your one-stop solution for IP address data. Use ipapi to enhance user experience, target specific audiences based on location and prevent fraud efficiently.
userstack
Bring user experience to perfection and identify any device, browser and operating system by parsing User-Agent strings in real-time. Detect any Browser, Device & OS in Real-Time.
Documentation
In this article we'll try to use the languagelayer API. You can read the official documentation on the languagelayer website.
How to use
Register to get a free API key
You need to go to languagelayer and register to get a free API key.
Using Raw PHP/Laravel
You can use raw PHP/Laravel to grab the data. Here is the sample code (which can be found at the documentation section):
$// set API Access Key
$access_key = 'YOUR_ACCESS_KEY';
// set query text
$query = 'Hello my friend, how are you today?';
// Initialize CURL:
$ch = curl_init('http://api.languagelayer.com/detect?access_key='.$access_key.'&query='.$query.'');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Store the data:
$json = curl_exec($ch);
curl_close($ch);
// Decode JSON response and store array:
$detection_result = json_decode($json, true);
Using Python 3
// set endpoint and your access key
var access_key = 'YOUR_ACCESS_KEY';
var query = 'Hello my friend, how are you?';
// AJAX call
$.ajax({
url: 'http://api.languagelayer.com/detect?access_key=' + access_key + '&query=' + encodeURIComponent(query),
dataType: 'jsonp',
success: function(json) {
// Access and use your preferred validation result objects
console.log(json.success);
}
});
This post is submitted by our members. Submit a new post.
Tags: Tutorials