bigluck / alfred2-currencyconverter

A simple Alfred 2 Currency Converter workflow
153 stars 31 forks source link

Invalid Query #24

Closed inspiredearth closed 6 years ago

inspiredearth commented 7 years ago

This workflow has ceased working in the past week or so. I get an "Invalid query" error, no matter what I do. It's been working fine for the past year or more. Has something changed online (with whatever APIs it interacts with), requiring it to be updated?

Nexilus commented 7 years ago

I have the same issue, checked and atleast the google finance API seems the same, however not sure if they have added any curl-rest restrictions or something, trying to poke around in the code to see if i can see anything from a novice point of view.

Nexilus commented 7 years ago

I may be wrong, but i think the alfred-update is what broke this plugin, i just did the google finance API-part in my own plugin with simple file_get_contents and dom-parsing, works great, so i believe alfred maybe changed the way script-filters work or something, becuase the backend seems fine. (Well except for the BTC stuff that is using an obsolete API)

NilsDannemann commented 7 years ago

Would love a solution for this as well. Was a great help so far!

AlexWang-16 commented 7 years ago

I'm also looking forward to a fix for this issue. This is a plugin I use regularly.

woodyc79 commented 7 years ago

Same here, would be great if it was fixed!

Enochenti commented 7 years ago

https://github.com/bigluck/alfred2-currencyconverter/pull/22

Here is a simple solution.

inspiredearth commented 7 years ago

Thanks @Enochenti . I see the workflow author has not yet pulled your new code into the workflow. Looks like this workflow may be abandoned. No updates in 5 years.

For those who are looking for a solution to this issue...

View the workflow in Finder. Edit the file: /libs/e4QuerySend.php

Change line 56. It is currently: $response = $this->app->sendHTTPRequest('http://www.google.com/finance/converter?'.http_build_query(array(

Change it to: $response = $this->app->sendHTTPRequest('https://finance.google.com/finance/converter?'.http_build_query(array( You can view the required changes here, https://github.com/bigluck/alfred2-currencyconverter/pull/22/files - courtesy of Enochenti. It will now work as before.

woodyc79 commented 7 years ago

It works. GREAT Jonathan - thank you!

bao-xingchen commented 7 years ago

Great job @jonathannz, thanks!

NilsDannemann commented 7 years ago

Amazing! Thanks a ton!

esthor commented 6 years ago

I get every other currency working that I try, except SEK (Swedish Krona)...any ideas?

viktorbijlenga commented 6 years ago

The Google Finance API seems to be slowly dying. Does anyone know if there is a good alternative? It might be time to replace it with something else.

@esthor I get every other currency working that I try, except SEK (Swedish Krona)...any ideas?

I get the same issue for SEK. On stackoverflow there seems to be similar issues beeing noticed. https://stackoverflow.com/questions/46070126/google-finance-json-stock-quote-stopped-working#comment85598584_46125977

inspiredearth commented 6 years ago

Darn. As of sometime this month (march 2018) the invalid query error has returned. I am guessing another change has occurred with the API.

Looks like Google have now dropped their finance API entirely. https://stackoverflow.com/a/49385274/1092677

inspiredearth commented 6 years ago

I suggest switching over to this workflow: http://www.packal.org/workflow/currency-exchange

It works well. It doesn't magically guess the currency when entering two digit country codes, as Currency Converter would, but so long as you put in the full three digit currency code, it's good to go.

@esthor : As a bonus, it works fine with SEK.

rauluranga commented 6 years ago

or you can edit the file /libs/e4QuerySend.php and replace the function queryGoogle with the following:

protected function queryGoogle()
{
    $this->requestService = 'Fixer IO';
    $response = $this->app->sendHTTPRequest('http://api.fixer.io/latest?'.http_build_query(array(
        'base' => $this->from,
        'symbols' => $this->to)), null, 300);
    $json = json_decode($response, true);
    if ($json['rates'][$this->to]){
        $this->responseFromAmount = $this->amount;
        $this->responseFromCurrency = $this->from;
        $this->responseToAmount = number_format($this->amount * floatval($json['rates'][$this->to]), 2);
        $this->responseToCurrency = $this->to;
        return $this->valid = true;
    }

    return $this->valid = false;
}

now uses: fixer.io using USD to MXN works for me! (haven't tested all currencies).

also you can rename the queryGoogle function to something more adequate, just remember to update the function call at sendRequest

AlexWang-16 commented 6 years ago

@rauluranga Thanks for posting the code. Just a side note, I don't think it is possible to replace queryGoogle with sendRequest because a function with that name already exist in the code.

rauluranga commented 6 years ago

yes i know, what i mean is that you can rename queryGoogle to something more adequate like queryFixer or something like that, but if you do that, you have to update the sendRequest function with the new name.

public function sendRequest()
{
    if ($this->from == 'BTC' || $this->to == 'BTC')
        return $this->queryBitcoin();
    return $this->queryFixer();
}
Denis4yk commented 6 years ago

Ehhh. I liked this package. Such a shame, that it's not supportable now.

ghost commented 6 years ago

@rauluranga That API is set to be shut-down June 1st 2018. The new API allows 1000 requests per-month on the free tier, whereas https://free.currencyconverterapi.com allows 100 per-hour.

This API endpoint is deprecated and will stop working on June 1st, 2018. For more information please visit: https://github.com/fixerAPI/fixer#readme

I've got an open pull-request with a working alternative at #26.

Edit: Seems you might have some luck with this hidden Google URL. Unsure how long it will stick around though. https://github.com/bigluck/alfred2-currencyconverter/pull/26#issuecomment-385298644