I was trying to get Alchemy working, and having some serious trouble. There is no documentation for where to place the API key, so it was only after I decided to look at the code that I noticed the README inside of the /modules folder indicating that I should paste the key into the api_key.txt file. However, it continued to state that "AlchemyAPI module needs key to work. See README." in the tagging widget.
After some fiddling about with the code, I decided to try changing line 9.
@$alchemyObj->loadAPIKey( drupal_get_path('module', 'Tagging')."\\modules\\tagging_alchemy_suggest\\api_key.txt");
To
@$alchemyObj->loadAPIKey( drupal_get_path('module', 'Tagging')."/modules/tagging_alchemy_suggest/api_key.txt");
And VOILA it started working!
Now, I'm on a linux server, and don't know exactly why this solved the problem, but could it be that drupal_get_path was returning forward slashes, and the tagging module was concatenating backslashes onto it?
Regardless, I recommend a configuration page and variable_get(). The lack of clear documentation and clumsiness of using a file to load the API key really does little to help simple users like myself.
Checking the AlchemyAPI files, the 'loadAPIKey()' function can be replaced by 'setAPIKey()' like so once there is a config page for entering API keys into the variable table.
6-10
function tagging_alchemy_suggest_tagging_suggestions($vid, $node) {
$alchemyObj = new AlchemyAPI();
try {
@$alchemyObj->setAPIKey( variable_get('tagging_alchemy_suggest_apikey', " "); //Use a single space for the default because if they keylength is less than 5 the function setAPIKey() throws an exception, "Error setting API key."
}
//...
Comments
Comment #1
eugenmayer commentedWell as this is only a contrib submodule and not even written by me. Making it a task.
I understnad your frustration, those documentations are pretty needed. Simple form alter on the tagging api page would do the job, as you described
Comment #2
Anonymous (not verified) commentedUnfortunately I did not even find the place where you did the change. In which file did you do it?
Comment #3
carlthuringer commentedtagging/modules/tagging_alchemy_suggest/tagging_alchemy_suggest.module
Line 9.
To
I'm not sure why there are escaped backslashes. loadAPIKey uses fopen() to open the file. PHP.net sez:
(My emphasis)
http://www.php.net/manual/en/function.fopen.php
Comment #4
Anonymous (not verified) commentedThanks. With this change it works fine.
Comment #5
goron commentedI'm having a similar problem - no suggestions are provided except for the "AlchemyPI module needs key to work...". I tried the solution provided, and there is no effect.
Any idea why this could be?