Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix -- Error with Nextcloud 22.1.0 even with API key set #97

Open
Joecowboy opened this issue Aug 17, 2021 · 1 comment
Open

Fix -- Error with Nextcloud 22.1.0 even with API key set #97

Joecowboy opened this issue Aug 17, 2021 · 1 comment

Comments

@Joecowboy
Copy link

I apologize for not making a pull request for this.

I am currently running:
Nextcloud v22.1.0
PHP version v8.0.8
Ubuntu v21.10

I kept kept getting the "Fatal error" after trying to add a City. Looked at the Console window on web browser and kept getting a 500 error with angular.min.js. So I updated to the latest build from Google. Then noticed after that in Nextcloud log PHP error with array in error check for if the json_decode array 502 check.

I made it to where you can now add the City ID in the City Name field to add your city. So now works with either City, State or the City ID.

You can get the City ID by doing a search here:
https://openweathermap.org/city/

Example: New York, New York
When you search it will pop up two choices to choose from:
New York City, US
New York, US

So if you choose the second one the url will return:
https://openweathermap.org/city/5128638

Take the 5128638 and past it into the Nextcloud Weather - Add City field textbox and click the ADD button. It will pull up the City by the City ID and will list the ID above the Add a city... However, when you refresh it will display the City name that you have chosen.

So, update the CityController.php by copying it into the following directory or wherever you have your Nextcloud installed.
/var/www/nextcloud/apps/weather/lib/Controller/CityController.php

You might not need the WeatherController.php update. However, I didn't test it without the update to it. Because,
I updated CityController.php to pull the City Name and Country from the json info to add this name to the database as an after thought to display the proper name instead of the City ID.
/var/www/nextcloud/apps/weather/lib/Controller/WeatherController.php

Same goes for the angular.min.js copy it to the following directory or to wherever you installed Nextcloud.
/var/www/nextcloud/apps/weather/js/angular.min.js

These fixes should not affect it from working on older builds of Nextcloud that this app supports.

Fix_For_Latest_Nextcloud_Build.zip

@Joecowboy Joecowboy changed the title Error with Nextcloud 22.1.0 even with API key set Fix -- Error with Nextcloud 22.1.0 even with API key set Aug 17, 2021
@Joecowboy
Copy link
Author

Joecowboy commented Aug 19, 2021

I apologize once again I do not have it setup to push a Pull Request.

You can now search on:
ZIP Code,Country Code
Latitude,Longitude
City ID
City,State,Country Code

So, update the following files by copying all of them into the following directories or wherever you have your Nextcloud installed.
/var/www/nextcloud/apps/weather/lib/Controller/CityController.php
/var/www/nextcloud/apps/weather/lib/Controller/WeatherController.php
/var/www/nextcloud/apps/weather/js/angular.min.js

Same as before it will initially show you your search results above the "Add a city...".
You can put in the text box search field the following examples:

Example for New York = ZIP Code,Country Code:
10001,US

Example for New York = City ID:
5128638

Example for New York = Latitude,Longitude:
40.7484,-73.9967

Example for regular search New York City:
New York City, New York, US

If you search on {City ID}, {Latitude,Longitude} or {ZIP Code,Country Code} when you refresh it will display City Name, Country Code, City ID. Added the City ID to the end to make sure it grabbed the correct city to display.

Fix_For_Latest_Nextcloud_Build.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant