I’m probably not supposed to use file_get_contents() What should I use? I’d like to keep it simple.
Warning: file_get_contents(http://en.wikipedia.org/w/api.php?action=query&titles=Your_Highness&prop=revisions&rvprop=content&rvsection=0): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden
The problem you are running into here is related to the MW API’s User-Agent policy – you must supply a
User-Agentheader, and that header must supply some means of contacting you.You can do this with
file_get_contents()with a stream context:Having said that, it might be considered more “standard” to use cURL, and this will certainly give you more control: