简体   繁体   中英

Fatal error: Call to undefined method with Wordnik API

Not sure if this is an Wordnik API issue or just a php error on my part. Here is my current code:

require('./wordnik/Swagger.php');
require('./wordnik/WordsApi.php');

$myAPIKey = '00144cdc1140c4192780f08c3f608399234240dcb560d3e4b';
$client = new APIClient($myAPIKey, 'http://api.wordnik.com/v4');

$wordApi = new WordApi($client);
$input = new WordObject();
$input->includePartOfSpeech='noun';
$input->excludePartOfSpeech='affix,article,connjunction,preposition,abbreviation,suffix';
$input->hasDictionaryDef='true';
$input->minCorpusCount='10000';
$input->maxCorpusCount='null';
$input->minDictionaryCount='20';
$input->maxDictionaryCount=null;
$input->minLength='4';
$input->maxLength='20';

$random_word = $wordApi->getRandomWord($input); //THIS IS THE ERROR LINE
print $random_word->text;

and here is the error I get: Fatal error: Call to undefined method WordApi::getRandomWord()

Any help is greatly appreciated. The error is happening on that line towards the bottom, just not sure why. Thank you.

getRandomWord() is defined in Word s Api (plural words).

  • You have: WordApi
  • You need: Word s Api

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM