CXuesong / WikiClientLibrary

/*🌻*/ Wiki Client Library is an asynchronous MediaWiki API client library targeting modern .NET platforms
https://github.com/CXuesong/WikiClientLibrary/wiki
Apache License 2.0
82 stars 16 forks source link

Issues with wikia.com migration to fandom.com #45

Closed aquilla12 closed 6 years ago

aquilla12 commented 6 years ago

The new domains seem to be causing issues. The library can still access wikis on *.wikia.com but throws various exceptions when trying to access *.fandom.com. So far I've had an error from Json.NET:

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
   at Newtonsoft.Json.JsonTextReader.ParseValue()
   at Newtonsoft.Json.Linq.JToken.ReadFrom(JsonReader reader, JsonLoadSettings se...

when using my own code with a WikiaSite. I got another different error when doing the same thing with a WikiSite in the library's ConsoleTestApplication1:

System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)

But when using a WikiaSite instead the first error could be reproduced. I don't currently have time to sort this out, but I'm working on debugging when I can.

aquilla12 commented 6 years ago

Note that to use a WikiaSite in ConsoleTestApplication1, the

<TargetFrameworks>net452</TargetFrameworks>

line in ConsoleTestApplication1.csproj will need to be changed to

<TargetFrameworks>net461</TargetFrameworks>
CXuesong commented 6 years ago

I've checked it out yesterday becaused I stumbled on the same Exceptions.

For the JSON parsing issue, like #38, the current HTTP 301 redirect is the root cause of the problem. Please use the MediaWiki API URL that won't cause any further HTTP redirections. E.g. use

https://warriors.fandom.com/api.php
https://warriors.fandom.com/it/api.php

rather than

https://warriors.wikia.com/api.php
https://it.warriors.wikia.com/api.php
- OR -
http://warriors.wikia.com/api.php
http://it.warriors.wikia.com/api.php

because the latter ones will cause HTTP 301 redirect from the old Wikia domain to the new FANDOM domain. The same goes to the http --> https redirect. It should be noted that, if you follow this rule, the SSL channel issue will just go away XD Then you should specify the following URLs as siteRootUrl parameter in WikiaSite's constructor:

https://warriors.wikia.com
https://it.warriors.wikia.com

For the SSL channel issue. You may test your specified MediaWiki API URL in the browser. For example, if you try to navigate to https://it.warriors.wikia.com in your browser, it's very likely that you will receive a similar SSL certificate warning.

p.s.

Though most of MediaWiki functionality will work as before, I'm not sure about FANDOM-spcific APIs, like Nirvana API & Wikia AJAX API. If you come across related problems, please create a new issue.

aquilla12 commented 6 years ago

Thank you. That seems to work. I'll let you know of any other issues I find.