Archive forUtilities

Yahoo! Mail Web Service APIs

Yahoo! announced today availability for its Mail Web Service APIs:

With the Yahoo! Mail Web Service APIs, you can build applications to perform tasks such as listing messages, displaying folders, and composing and sending messages.

Here's an authentication example from their samples:

<?php
// test.php — Test Yahoo! Browser-Based Authentication
// A simple auth exmaple.
// Author: Jason Levitt
// Date: November 20th, 2006
// Version 1.0
//

// Edit these. Change the values to your Application ID and Secret
define("APPID", 'JzkILqzIkY1xxxxxxxxxIaGILaRWClvO');
define("SECRET", '10de7e35xxxxxxxxxe5749207495ed');

// Include the proper class file
$v = phpversion();
if ($v[0] == '4′) {
include("ybrowserauth.class.php4″);
} elseif ($v[0] == '5′) {
include("ybrowserauth.class.php5″);
} else {
die('Error: could not find the bbauth PHP class file.');
}

function CreateContent() {

$authObj = new YBrowserAuth(APPID, SECRET);

// If Yahoo! isn't sending the token, then we aren't coming back from an
// authentication attempt
if (empty($_GET["token"])) {
// You can send some data along with the authentication request
// In this case, the data is the string 'some_application_data'
echo 'You have not signed on using BBauth yet<br /><br />';
echo '<a href="'.$authObj->getAuthURL('some_application_data', true).'">Click here to authorize</a>';
return;
}

// Validate the sig
if ($authObj->validate_sig()) {
echo '<h2>BBauth authentication Successful</h2>';
echo '<h3>The user hash is: '.$authObj->userhash.'</h3>';
echo '<b>appdata value is:</b> '. $authObj->appdata . '<br />';
} else {
die('<h1>BBauth authentication Failed</h1> Possible error msg is in $sig_validation_error:<br />'. $authObj->sig_validation_error);
}

return;
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8″ />
</head>
<body>
<div id="look">
<h2>Test BBauth </h2>
<div>
<?php CreateContent(); ?>
</div>
<div id="content">
</div>
</div>
</body>
</html>

They also offers $10 commission for developers which refer clients to premium Yahoo! Mail account.

Comments

Yahoo Spell Checker API

Another web service available from Yahoo is online spell checker. Thsi service is similar with Yahoo web search: you provide all parameters with REST and get results as XML, JSON or serialized PHP. URL used for this service is http://api.search.yahoo.com/WebSearchService/V1/spellingSuggestion and its description with all parameters is at http://developer.yahoo.net/search/web/V1/spellingSuggestion.html.

Here's an example from JavaScript using JSON:

<script language=JavaScript>
function ws_results(obj) {
alert("Correct spelling of 'someting' is '"+obj.ResultSet.Result+"'");
}
</script>
<script type="text/javascript"
src="http://api.search.yahoo.com/WebSearchService/V1/spellingSuggestion?appid=YahooDemo&query=someting&output=json&callback=ws_results">
</script>

And something similar with serialized PHP:

$request =  'http://api.search.yahoo.com/WebSearchService/V1/spellingSuggestion?appid=YahooDemo&query=someting&output=php';

$response = implode('',file($request));

if ($response === false) {
 die('Request failed');
}

$phpobj = unserialize($response);

echo "Correct spelling of 'someting' is '{$phpobj['ResultSet']['Result']}'"; 

Simply, isn't it? There is the same 5000 queries limit per day per IP for this web service.

Comments