Jump to content

Wordreference workflow with inline results


Recommended Posts

Hello,

 

I've been trying to figure out how to create a wordreference.com workflow with inline results. Right now I'm using a simple workflow that opens the relevant translation page in a browser, but my feeble attempt to create a more advanced version by adapting the UrbanDictionary workflow (and then fiddling with the result) is not working.

 

Wordreference.com does offer API keys (http://www.wordreference.com/docs/api.aspx), which seems to be important for this kind of thing, so I think it should be possible for a person who actually knows what they're doing. 

 

For what little it's worth, here's my current attempt, totally just adapted from the Danylo Kostyshyn's UrbanDictionary workflow:

 

 

require_once('workflows.php');
$w = new Workflows();
 
$query = urlencode( $argv[1] );
 
$url = "http://api.wordreference.com/0.8/[api key inserted here]/fren/$query";
$suggestions = $w->request( $url );
 
$suggestions = json_decode( $suggestions );
 
foreach( $suggestions->list as $suggest ):
$w->result( 
'na', 
$query, 
$suggest->term, 
$suggest->usage, 
'icon.png', 
'yes' );
endforeach;
 
echo $w->toxml();

 

 

 

That version's attempting to translate French to English, but I'd like to also access English to French and English/Italian translations.

 

 

Thanks very much in advance for your help!

Link to comment

Hello,

 

I've been trying to figure out how to create a wordreference.com workflow with inline results. Right now I'm using a simple workflow that opens the relevant translation page in a browser, but my feeble attempt to create a more advanced version by adapting the UrbanDictionary workflow (and then fiddling with the result) is not working.

 

Wordreference.com does offer API keys (http://www.wordreference.com/docs/api.aspx), which seems to be important for this kind of thing, so I think it should be possible for a person who actually knows what they're doing. 

 

For what little it's worth, here's my current attempt, totally just adapted from the Danylo Kostyshyn's UrbanDictionary workflow:

 

 

That version's attempting to translate French to English, but I'd like to also access English to French and English/Italian translations.

 

 

Thanks very much in advance for your help!

 

I didn't try all the code but I did look into this briefly and it looks like you are using the wrong api endpoint. Try..

$url = "http://api.wordreference.com/0.8/apikey/json/fren/$query";

Adding /json/ in the path sets the output format to json.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...