我正在尝试使用 Wordnik PHP API,但遇到了一些麻烦。我尝试使用 getDefinitions 方法,但它返回错误:Notice: Trying to get property of non-object in C:\xampp\htdocs\index.php on line 18
。
这是以下代码:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form method="post">
<input type="text" placeholder="First Word" name="word1">
<input type="submit" placeholder="Compare">
</form>
<?php
require('./wordnik/Swagger.php');
$APIKey = '342eac9900e703079b0050d5f7008eab962195189e75bfbcb';
$client = new APIClient($APIKey, 'http://api.wordnik.com/v4');
$word1 = $_POST['word1'];
$wordApi = new WordApi($client);
$word1 = $wordApi->getDefinitions($word1, null, null);
print $word1->text;
?>
</body>
</html>