Skip to content
This repository has been archived by the owner on Apr 29, 2023. It is now read-only.

Please read the Terms of Service #5

Open
geira opened this issue Oct 16, 2018 · 6 comments
Open

Please read the Terms of Service #5

geira opened this issue Oct 16, 2018 · 6 comments

Comments

@geira
Copy link

geira commented Oct 16, 2018

Hi, the current code is in violation of TOS and will get you throttled or possibly blocked. As stated in the Terms of Use, you should "add a User Agent-string (UA) in the request with the application/domain name and version number". In case of a library like this you should use your site domain name + the name/version of this library so we can pinpont the issue in case of problems.

Trying to spoof by posing as a browser ('Mozilla/5.001 (windows; U; NT4.0; en-US; rv:1.0) Gecko/25250101') is considered abuse, is easily detectable and will get your ip address blacklisted if you generate significant traffic.

@vlasovdmitri
Copy link

Hi, there is another example of implementing data import on PHP for JSON and API 2.0?

@geira
Copy link
Author

geira commented Sep 20, 2021

Unfortunately we don't have the resources to make example code in every programming language. However generic instructions can be found here:

https://docs.api.met.no/doc/GettingStarted
https://docs.api.met.no/doc/locationforecast/HowTO
https://docs.api.met.no/doc/FAQ

@geira
Copy link
Author

geira commented Sep 20, 2021

Also, since the last commit our most popular API products (e.g. locationforecast, sunrise) have been changed to new versions, so this code is most likely no longer functional and needs to be rewritten.

@vlasovdmitri
Copy link

vlasovdmitri commented Sep 20, 2021

Also, since the last commit our most popular API products (e.g. locationforecast, sunrise) have been changed to new versions, so this code is most likely no longer functional and needs to be rewritten.

If you change the link to protected $apiRequest = "https://api.met.no/weatherapi/locationforecast/2.0/classic?"; then the code works

Unfortunately we don't have the resources to make example code in every programming language. However generic instructions can be found here:

https://docs.api.met.no/doc/GettingStarted
https://docs.api.met.no/doc/locationforecast/HowTO
https://docs.api.met.no/doc/FAQ

Thanks. I just wanted to quickly start using the new ready-made solution. I myself am not that good at programming to quickly solve such problems.

@geira
Copy link
Author

geira commented Sep 20, 2021

If you change the link to protected $apiRequest = "https://api.met.no/weatherapi/locationforecast/2.0/classic?"; then the code works

Possibly. However it still violates our TOS, and is likely to get blocked in the future. Here's an example in PHP which has worked for other clients:

$opts = array(
  'http'=>array(
    'method'=>"GET",
    'header'=>"User-Agent: https://github.com/pionl/METno\r\n"
  )
);

$context = stream_context_create($opts);

file_get_contents($url, false, $context) 

See these links for more information:

https://www.php.net/manual/en/function.file-get-contents.php
https://www.php.net/manual/en/function.stream-context-create.php

@pionl
Copy link
Owner

pionl commented Jan 28, 2022

@geira Thank you for the info. For past years i do not use this any more. If some one wants to make PR I'm gonna merge it. But still this repo needs some upgrading (not in my intention).

I'm gona probably archive the repository in some time.

Best regards

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

No branches or pull requests

3 participants