获取API网址请求

时间:2013-07-17 18:59:34

标签: php api get synonym

我已注册了同义词API ..请参阅the details on this page

我在我的PHP代码中实现这个问题。

如果我将链接复制并粘贴到网络浏览器中,我可以看到结果没问题。

我不希望手动输入单词,而是希望链接中包含一个变量,即相关单词$variable_with_word_stored,如下所示。

    http://words.bighugelabs.com/api/2/xxxxxxxx/$variable_with_word_stored/php 

    //format could be php (I would unserialize)..or json..I could decode it?

任何想法的家伙?感谢。

2 个答案:

答案 0 :(得分:0)

听起来你的意思是希望调用该网页的结果并将其存储在变量中。您应该做的是在代码中向该页面发送http get请求。

使用php检查curl,您可以向您请求的网址发送http请求,捕获结果并通过json_decode解析

http://php.net/manual/en/curl.examples-basic.php

答案 1 :(得分:0)

尝试这样,也许你不需要卷曲:

$key = "xxxxxxxx";
$word = "love";

echo file_get_contents("http://words.bighugelabs.com/api/2/$key/$word/php");