Dear all, I have encountered a problem when I invoke Wiki API in C# by "POST". The result I get is that:
<?xml version="1.0" ?> - <api> - <query> - <allpages> <p pageid="290" ns="0" title="A" /> <p pageid="13547196" ns="0" title="A"" /> <p pageid="9068190" ns="0" title="A"H" /> <p pageid="9068184" ns="0" title="A"h" /> <p pageid="9192091" ns="0" title="A$" /> <p pageid="27551355" ns="0" title="A$$hole: How I Got Rich & Happy by Not Giving a Damn About Anyone & How You Can, Too" /> <p pageid="27551358" ns="0" title="A$$hole: How I Got Rich and Happy by Not Giving a Shit About You" /> <p pageid="3566260" ns="0" title="A&A" /> <p pageid="11298846" ns="0" title="A&AEE" /> <p pageid="24081644" ns="0" title="A&AS" /> <p pageid="28397693" ns="0" title="A&A (disambiguation)" /> <p pageid="20546645" ns="0" title="A&A Building" /> My code: String WikiURL = "http://en.wikipedia.org/w/api.php"; Encoding myEncoding = Encoding.GetEncoding("UTF-8"); Uri url = new Uri(WikiURL); HttpWebRequest http = (HttpWebRequest)HttpWebRequest.Create(url); http.Method = "POST"; http.ContentType = "application/x-www-form-urlencoded"; http.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3; MS-RTC LM 8)"; http.Accept = "image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*"; http.Headers.Add("Accept-Language","en-us"); http.Headers.Add("Accept-Charset","utf-8"); byte[] bytePostDdata = Encoding.UTF8.GetBytes(postData); http.ContentLength = bytePostDdata.Length; using (Stream postStream = http.GetRequestStream()) { postStream.Write(bytePostDdata, 0, bytePostDdata.Length); postStream.Close(); } HttpWebResponse response = http.GetResponse() as HttpWebResponse; StreamReader stream = new StreamReader(response.GetResponseStream(), myEncoding); string result = stream.ReadToEnd(); response.Close(); stream.Close(); It's wrong; first the pageid is not right ; sencond, the title is not available in the wiki. The encoding and decoding both use "utf-8". I have tried many methods, but I still can't solve it. Please give me a help. I need that. But when I access wiki in IE8.0 or firefox by "GET", the result is right. I can't get where is wrong. -----Original Message----- From: mediawiki-api-boun...@lists.wikimedia.org [mailto:mediawiki-api-boun...@lists.wikimedia.org] On Behalf Of mediawiki-api-requ...@lists.wikimedia.org Sent: Tuesday, January 25, 2011 10:35 AM To: mediawiki-api@lists.wikimedia.org Subject: Mediawiki-api Digest, Vol 43, Issue 5 Send Mediawiki-api mailing list submissions to mediawiki-api@lists.wikimedia.org To subscribe or unsubscribe via the World Wide Web, visit https://lists.wikimedia.org/mailman/listinfo/mediawiki-api or, via email, send a message with subject or body 'help' to mediawiki-api-requ...@lists.wikimedia.org You can reach the person managing the list at mediawiki-api-ow...@lists.wikimedia.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Mediawiki-api digest..." Today's Topics: 1. Re: Retrieving images instead of math markup (Alex Brollo) 2. What is the Full URL of the images returned by a wikipedia query... (A O) 3. Re: What is the Full URL of the images returned by a wikipedia query... (Betacommand) 4. Re: What is the Full URL of the images returned by a wikipedia query... (Brad Jorsch) 5. header intact (Zhihua Wu) ---------------------------------------------------------------------- Message: 1 Date: Thu, 20 Jan 2011 17:31:37 +0100 From: Alex Brollo <alex.bro...@gmail.com> Subject: Re: [Mediawiki-api] Retrieving images instead of math markup To: "MediaWiki API announcements & discussion" <mediawiki-api@lists.wikimedia.org> Message-ID: <aanlktik0xow59-tgtyykew7xaxegnvz67fxnpra2o...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" 2011/1/20 Gabriel Sandor <gabi.t.san...@gmail.com> > So eventually I tried this and indeed it works as expected. I have one > more question though. > > I've seen that most of the complex math formulas are converted into > .png images with some long names - for instance, the > <math>\iiiint\limits_F \, dx\,dy\,dz\,dt</math> formula (triple > integral) is converted into an image with the name > 49005f50f3ba2dfade3a265ebe363ee9.png. I'd like to know, is this file > name unique for each formula ? And is it persisted on the wiki's > server indefinitely, just like other images in articles ? To be more > clear, is the triple integral formula always going to be associated to > this 49005f50f3ba2dfade3a265ebe363ee9.png > file ? > I'm trying to implement a cache mechanism in my app that tries to also > deal with images generated from math markup (besides usual images in > articles), that's why I have this curiosity. I'd like to know if I can > safely associate a math markup string with a file name so that there's > no need to retrieve the image from the server again when I encounter that formula. > > On Mon, Dec 13, 2010 at 1:23 PM, Roan Kattouw <roan.katt...@gmail.com>wrote: > >> 2010/12/13 Gabriel Sandor <gabi.t.san...@gmail.com>: >> > Is it possible to retrieve (preferably via the MediaWiki API) an >> > image representing a mathematical formula given in the <math> tags >> > that are frequently encountered in Wikipedia articles ? >> There's no direct way to do this, although I guess it could be >> implemented. A workaround would be to do something like >> http://en.wikipedia.org/w/api.php?action=parse&text= >> <math>\gamma=\frac{1}{\sqrt{1-v^2}}</math>&format=yamlfm >> , which will give you the HTML generated for this <math> tag, which >> could be an image (like in this case), or HTML if the formula is >> sufficiently simple (try a^2+b^2=c^2 for instance). >> >> Roan Kattouw (Catrope) >> > Yes, the name is unique, I discovered by reverse engineering that it is merely "the MD5 transformation of the normalized TeX code". An intelligent trick that, I guess, points directly on the png image without any need to calculate it again: I presume that the name only is calculated, and, if the png exists, it is uploaded! The "normalized TeX code", I guess, is the text that you can see browsing the html code, into the "alt" attribute of the image tag. There are online free MD5 coders somewhere into the web, try the conversion of alternate text. Nothing of this is documented, I discovered it by myself; can be, I'm absolutely wrong. :-) Alex -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.wikimedia.org/pipermail/mediawiki-api/attachments/20110120/9cc2 4a99/attachment-0001.htm ------------------------------ Message: 2 Date: Mon, 24 Jan 2011 10:22:06 -0500 From: A O <aot...@hotmail.com> Subject: [Mediawiki-api] What is the Full URL of the images returned by a wikipedia query... To: <mediawiki-api@lists.wikimedia.org> Message-ID: <blu155-w18c723b106b9c5bb80a6c1cd...@phx.gbl> Content-Type: text/plain; charset="iso-8859-1" If I run the following URL, I receive the following xml in return. My question is... The xml returned is meant to be a list of images on a specific page, which it is!BUT I don't know how I would reference these images in order to have them appear in my page. What is the full URL of these images? ANyone? http://en.wikipedia.org/w/api.php?action=query&list=allimages&ailimit=10&aif rom=New_Jersey_Devils&aiprop=dimensions|mime <?xml version="1.0"?> <api> <query> <allimages> <img name="New_Jersey_Devils'_Retired_Numbers.jpg" size="3587985" width="4000" height="3000" mime="image/jpeg" /> <img name="New_Jersey_Devils_logo.svg" size="6176" width="159" height="160" mime="image/svg+xml" /> <img name="New_Jersey_Devils_old_logo.svg" size="6206" width="159" height="160" mime="image/svg+xml" /> <img name="New_Jersey_Drive.jpg" size="70297" width="580" height="864" mime="image/jpeg" /> <img name="New_Jersey_Drive_2.jpg" size="11227" width="200" height="197" mime="image/jpeg" /> <img name="New_Jersey_Drive_Vol_1.jpg" size="16005" width="240" height="240" mime="image/jpeg" /> <img name="New_Jersey_Grizzlies.PNG" size="36160" width="150" height="150" mime="image/png" /> <img name="New_Jersey_Guber_1997.PNG" size="5910" width="251" height="450" mime="image/png" /> <img name="New_Jersey_Guber_2001.PNG" size="5902" width="251" height="450" mime="image/png" /> <img name="New_Jersey_Guber_2005.PNG" size="5835" width="251" height="450" mime="image/png" /> </allimages> </query> <query-continue> <allimages aifrom="New Jersey Human Services Police.jpg" /> </query-continue> </api> -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.wikimedia.org/pipermail/mediawiki-api/attachments/20110124/3e93 38bb/attachment-0001.htm ------------------------------ Message: 3 Date: Mon, 24 Jan 2011 10:25:07 -0500 From: Betacommand <betacomm...@gmail.com> Subject: Re: [Mediawiki-api] What is the Full URL of the images returned by a wikipedia query... To: "MediaWiki API announcements & discussion" <mediawiki-api@lists.wikimedia.org> Message-ID: <aanlktin_9djnbe6vnlpmswwun6kl5cm9of_-nfdon...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" use http://en.wikipedia.org/w/api.php?action=query&list=allimages&ailimit=10&aif rom=New_Jersey_Devils&aiprop=dimensions|mime|url On Mon, Jan 24, 2011 at 10:22 AM, A O <aot...@hotmail.com> wrote: > If I run the following URL, I receive the following xml in return. > > My question is... The xml returned is meant to be a list of images on > a specific page, which it is! > BUT I don't know how I would reference these images in order to have > them appear in my page. What is the full URL of these images? ANyone? > > > http://en.wikipedia.org/w/api.php?action=query&list=allimages&ailimit= > 10&aifrom=New_Jersey_Devils&aiprop=dimensions|mime<http://en.wikipedia > .org/w/api.php?action=query&list=allimages&ailimit=10&aifrom=New_Jerse > y_Devils&aiprop=dimensions%7Cmime> > > <?xml version="1.0"?><api> > <query> > <allimages> > <img name="New_Jersey_Devils'_Retired_Numbers.jpg" size="3587985" width="4000" height="3000" mime="image/jpeg" /> > <img name="New_Jersey_Devils_logo.svg" size="6176" width="159" height="160" mime="image/svg+xml" /> > <img name="New_Jersey_Devils_old_logo.svg" size="6206" width="159" height="160" mime="image/svg+xml" /> > <img name="New_Jersey_Drive.jpg" size="70297" width="580" height="864" mime="image/jpeg" /> > <img name="New_Jersey_Drive_2.jpg" size="11227" width="200" height="197" mime="image/jpeg" /> > <img name="New_Jersey_Drive_Vol_1.jpg" size="16005" width="240" height="240" mime="image/jpeg" /> > <img name="New_Jersey_Grizzlies.PNG" size="36160" width="150" height="150" mime="image/png" /> > <img name="New_Jersey_Guber_1997.PNG" size="5910" width="251" height="450" mime="image/png" /> > <img name="New_Jersey_Guber_2001.PNG" size="5902" width="251" height="450" mime="image/png" /> > <img name="New_Jersey_Guber_2005.PNG" size="5835" width="251" height="450" mime="image/png" /> > </allimages> > </query> > <query-continue> > <allimages aifrom="New Jersey Human Services Police.jpg" /> > </query-continue></api> > > > _______________________________________________ > Mediawiki-api mailing list > Mediawiki-api@lists.wikimedia.org > https://lists.wikimedia.org/mailman/listinfo/mediawiki-api > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.wikimedia.org/pipermail/mediawiki-api/attachments/20110124/958e 8803/attachment-0001.htm ------------------------------ Message: 4 Date: Mon, 24 Jan 2011 10:43:31 -0500 From: Brad Jorsch <b-jor...@alum.northwestern.edu> Subject: Re: [Mediawiki-api] What is the Full URL of the images returned by a wikipedia query... To: MediaWiki API announcements & discussion <mediawiki-api@lists.wikimedia.org> Message-ID: <20110124154331.ga21...@anomie.yi.org> Content-Type: text/plain; charset=us-ascii On Mon, Jan 24, 2011 at 10:22:06AM -0500, A O wrote: > > The xml returned is meant to be a list of images on a specific page, > which it is! No it isn't. It's a list of the first 10 images (out of all images) starting from the first one whose name sorts after the string "New Jersey Devils". They aren't all used on the same page, and it's possible some are not used in any page at all. If you want the list of images on a particular page, use prop=images instead of list=allimages. In your case, you'd probably want to use it as a generator and combine it with prop=imageinfo, something like this: http://en.wikipedia.org/w/api.php?action=query&titles=New_Jersey_Devils&gene rator=images&gimlimit=10&prop=imageinfo&iiprop=url|dimensions|mime ------------------------------ Message: 5 Date: Tue, 25 Jan 2011 10:34:35 +0800 From: "Zhihua Wu" <wuzh...@gmail.com> Subject: [Mediawiki-api] header intact To: <mediawiki-api@lists.wikimedia.org> Message-ID: <000001cbbc38$6b896cf0$429c46d0$@gmail.com> Content-Type: text/plain; charset="us-ascii" Hi, I have been subscribed to the list. And I want to know how to solve my problem proposed before. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.wikimedia.org/pipermail/mediawiki-api/attachments/20110125/90c3 9579/attachment.htm ------------------------------ _______________________________________________ Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api End of Mediawiki-api Digest, Vol 43, Issue 5 ******************************************** _______________________________________________ Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api