2013-07-17 156 views
1

我已經簽署了一個同義詞API ..看到the details on this pageGET請求的API URL

我有我的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? 

任何想法傢伙?謝謝。

回答

0

這聽起來像你的意思是你想調用該網頁的結果並將其存儲在一個變量中。你應該做的是發送一個HTTP請求到該代碼中的頁面。

退房使用curl用PHP,你可以發送一個HTTP請求到您請求的URL,捕捉結果返回並解析它通過json_decode

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

0

嘗試這樣,也許你不需要捲曲:

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

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