I finally had the time to dive back into this project and managed to get everything working exactly as I was hoping.... locally! After uploading the game to a server it suddenly stops working again. From my knowledge with Flash games and further testing, I believe it has to do with the cross-domain-policy for Wikitionary, which is usually an xml set up on the server.
While attempting to locate the current Wikimedia policy I ran into random comments with warnings about the security risks involved in using the cross-domain-policy. I also discovered that Bugfix 1.9 states "Partial support for Flash cross-domain-policy filtering."
I'm not sure where to go from here. Is there a confirmed and allowed method to programmatically pull the rendered HTML from Wiktionary that can then be parsed?
Thanks, Aaron.
On Sun, Apr 25, 2010 at 3:43 PM, Conrad Irwin <conrad.irwin@googlemail.com
wrote:
On 04/25/2010 11:32 PM, Aaron Ward wrote:
Hello there!
I'm a Flash Video Game Developer working on a word based game. I
stumbled
across the MediaWiki API component during my research and I've been
testing
it locally in the game to retrieve word definitions and displaying them
in
the game for the player. In general, everything works great locally, but there's a few odd issues that I'd like to get worked out, if possible.
As in the forum, you can get definitions from Wiktionary, though it's not quite that simple (there is not a "data" API to Wiktionary, you can only get the page text).
You have a choice between:
- Getting the raw text of the page with the API and extracting the
lines that start with a # for definitions. 2. Getting the rendered HTML of the page as normal, and extracting the contents of the <ol> in <div id="bodyContent">. 3. Creating something easier to use with the pre-extracted lists at http://toolserver.org/~enwikt/definitionshttp://toolserver.org/%7Eenwikt/definitions .
In an ideal world there would be a public API using the data from (3), but no one has done that yet.
Conrad
2010/6/9 Aaron Ward edugamer@gmail.com:
I finally had the time to dive back into this project and managed to get everything working exactly as I was hoping.... locally! After uploading the game to a server it suddenly stops working again. From my knowledge with Flash games and further testing, I believe it has to do with the cross-domain-policy for Wikitionary, which is usually an xml set up on the server.
While attempting to locate the current Wikimedia policy I ran into random comments with warnings about the security risks involved in using the cross-domain-policy. I also discovered that Bugfix 1.9 states "Partial support for Flash cross-domain-policy filtering."
I'm not sure where to go from here. Is there a confirmed and allowed method to programmatically pull the rendered HTML from Wiktionary that can then be parsed?
You can use JSON callbacks, which basically means you (dynamically) add something like this to the HTML of your page:
<script type="text/javascript" src="http://en.wiktionary.org/w/api.php?format=json&callback=myFunc¶metersHere"></script>
Which will cause the function myFunc() to be executed with the results of the API call passed as a parameter. However, for security reasons, all callbacks will be treated as originating from anonymous users, and they can't be used to get restricted informations, get tokens, edit stuff or anything like that.
Roan Kattouw (Catrope)
Thanks for the tip Roan, but I'm afraid I'm still having trouble with this. I just spent the last couple hours researching JSON callbacks, as I have never had a need to learn about it more until now. I'm specifically trying to pull the information from within a Flash AS3 program, so I also did a bit of research about reading and decoding JSON with ActionScript 3. Unfortunately, I just appear to be spinning my wheels and not making any real progress. I'm sure I'm doing something wrong, but haven't yet been able to figure out what that is. Hopefully somebody here might be able to spot it.
Here's a link to the tutorial I'm using for using JSON with AS3, but will summarize for brevity. ( http://www.cakesgood.com/2009/04/flash-cs3-actionscript-30-json-keep-it_3277...)
We basically use Flash's net classes to request the contents at the specified URL and then decode the expected JSON response using the Adobe core library (downloadable from the tutorial). Here is the resulting ActionScript 3 code:
/////////////////////////////////////////////////////////////AS3\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ import flash.net.URLRequest; import flash.net.URLLoader; import flash.events.*; import com.adobe.serialization.json.JSON;
var loader:URLLoader = new URLLoader(); var request:URLRequest = new URLRequest();
request.url = " http://en.wiktionary.org/w/api.php?format=json&callback=myFunc&actio..." ; loader.load(request); loader.addEventListener(Event.COMPLETE, decodeJSON);
function decodeJSON(event:Event):void { trace(event.target.data); var loader:URLLoader = URLLoader(event.target); var People:Array = JSON.decode(loader.data); trace(People); } /////////////////////////////////////////////////////////////AS3\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
This results in a parse error and printing out the loader.data will display: myFunc(["play",["play"]])
I suspect this is due to an incorrect usage of the API call, but further testing and research have not produced any better results. I can't seem to get any JSON formatted call to return any contents from the page. During my research I stumbled on a collection of mediawiki-api emails where another developer (Borort) was having trouble converting XML to JSON and explained his reason for not exporting directly to JSON as: ( http://old.nabble.com/Problem-converting-new-XML-format-to-JSON-td24242786.h... )
"The reason that i don't use format=*json* is it will not return the description and url of the result.."
Roan's response to this was:
"Actually, both the *JSON* opensearch format and the XML opensearch format are documented standards, but with different fields. IIRC, the opensearch module will refuse to output anything but these two, and will output *JSON* even if you set format=php. It's only intended to be used for browser search plugins (*JSON* for Firefox, XML for IE); for other purposes, you're probably better off using list=search or list=allpages&apprefix=Foo instead.
Roan Kattouw (Catrope)"
Am I simply using the incorrect api calls for this? Or should I be approaching this from an entirely different angle? The end goal is to search Wiktionary for the definition of a dynamically submitted word from within a Flash AS3 program, so I don't think there should be any problems with restricted information.
Thanks again, Aaron.
On Wed, Jun 9, 2010 at 3:00 AM, Roan Kattouw roan.kattouw@gmail.com wrote:
2010/6/9 Aaron Ward edugamer@gmail.com:
I finally had the time to dive back into this project and managed to get everything working exactly as I was hoping.... locally! After uploading
the
game to a server it suddenly stops working again. From my knowledge with Flash games and further testing, I believe it has to do with the cross-domain-policy for Wikitionary, which is usually an xml set up on
the
server.
While attempting to locate the current Wikimedia policy I ran into random comments with warnings about the security risks involved in using the cross-domain-policy. I also discovered that Bugfix 1.9 states "Partial support for Flash cross-domain-policy filtering."
I'm not sure where to go from here. Is there a confirmed and allowed
method
to programmatically pull the rendered HTML from Wiktionary that can then
be
parsed?
You can use JSON callbacks, which basically means you (dynamically) add something like this to the HTML of your page:
<script type="text/javascript" src=" http://en.wiktionary.org/w/api.php?format=json&callback=myFunc¶metersHere "></script>
Which will cause the function myFunc() to be executed with the results of the API call passed as a parameter. However, for security reasons, all callbacks will be treated as originating from anonymous users, and they can't be used to get restricted informations, get tokens, edit stuff or anything like that.
Roan Kattouw (Catrope)
Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
2010/6/9 Aaron Ward edugamer@gmail.com:
Am I simply using the incorrect api calls for this? Or should I be approaching this from an entirely different angle? The end goal is to search Wiktionary for the definition of a dynamically submitted word from within a Flash AS3 program, so I don't think there should be any problems with restricted information.
Yes, you're taking a totally wrong angle here. Any cross-domain restrictions are imposed by Flash or whatever it is you're using to send your HTTP requests. The API or WMF's servers have nothing to do with this: Flash or the browser or whatever is preventing your requests from ever being sent.
These cross-domain restrictions are being imposed for security reasons. I only know about the restrictions web browsers impose, where JSON callbacks allow for a 'loophole' that allows cross-domain request in a limited way but is still secure. Again, the API implements JSON callbacks so this technique can be used, but doesn't impose the restrictions that cause people to use callbacks in the first place, that's done by the browser. I'm afraid I can't help you with restrictions imposed by Flash, as I'm not familiar with them.
Roan Kattouw (Catrope)
On Wed, Jun 9, 2010 at 3:59 PM, Roan Kattouw roan.kattouw@gmail.com wrote:
2010/6/9 Aaron Ward edugamer@gmail.com:
Am I simply using the incorrect api calls for this? Or should I be approaching this from an entirely different angle? The end goal is to search Wiktionary for the definition of a dynamically submitted word from within a Flash AS3 program, so I don't think there should be any problems with restricted information.
Yes, you're taking a totally wrong angle here. Any cross-domain restrictions are imposed by Flash or whatever it is you're using to send your HTTP requests. The API or WMF's servers have nothing to do with this: Flash or the browser or whatever is preventing your requests from ever being sent.
Actually with flash, the WMF servers do have something to do with it. Flash would require[1] a crossdomain.xml file on them to permit its access.
1 - http://www.adobe.com/devnet/flashplayer/articles/cross_domain_policy.html
From what I've been able to find in random posts, comments, and articles
regarding Wikimedia, a universal cross-domain-policy xml does not exist on the WMF servers specifically due to a potential security risk, which is mentioned in the article QQ just linked. The author of that article also states that these security issues are limited to the specific directory where the crossdomain.xml file is located and that the developer would have to specifically call on that file to facilitate the connection. If that is true, might it be possible to setup a directory (if one doesn't already exist) where basic, read-only queries can be implemented to open up the WikiMedia content to Flash developers?
Alternatively, I was wondering if it might be possible to set my server up as a sort of proxy to go between Wiktionary and the Flash program. If I can use PHP, JavaScript, or HTML to query the WMF database and retrieve the desired definition, then I should be able to forward that information on to the game that requested it using my own cross-domain-policy.
Any thoughts would be appreciated! Aaron.
On Wed, Jun 9, 2010 at 4:05 PM, OQ overlordq@gmail.com wrote:
On Wed, Jun 9, 2010 at 3:59 PM, Roan Kattouw roan.kattouw@gmail.com wrote:
2010/6/9 Aaron Ward edugamer@gmail.com:
Am I simply using the incorrect api calls for this? Or should I be approaching this from an entirely different angle? The end goal is to
search
Wiktionary for the definition of a dynamically submitted word from
within a
Flash AS3 program, so I don't think there should be any problems with restricted information.
Yes, you're taking a totally wrong angle here. Any cross-domain restrictions are imposed by Flash or whatever it is you're using to send your HTTP requests. The API or WMF's servers have nothing to do with this: Flash or the browser or whatever is preventing your requests from ever being sent.
Actually with flash, the WMF servers do have something to do with it. Flash would require[1] a crossdomain.xml file on them to permit its access.
1 - http://www.adobe.com/devnet/flashplayer/articles/cross_domain_policy.html
Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
2010/6/10 Aaron Ward edugamer@gmail.com:
Alternatively, I was wondering if it might be possible to set my server up as a sort of proxy to go between Wiktionary and the Flash program. If I can use PHP, JavaScript, or HTML to query the WMF database and retrieve the desired definition, then I should be able to forward that information on to the game that requested it using my own cross-domain-policy.
This is probably the best solution.
Roan Kattouw (Catrope)
Hello again,
I've spent a bit of time looking through the JavaScript documentation, PHP documentation, and the API documentation but haven't been able to get any kind of return data from the API. I started by trying to use the example Roan provided in JavaScript and learned a bit more about function usage in JavaScript, but I'm still getting nothing back from wiktionary. Could someone provide me with a simple, working example that actually returns a value?
I've tried a number of different things, including the get_file_contents in PHP (which did echo a barebone representation of the page I loaded), but I've reverted back to the example Roan provided. Again, I'm trying to get the definition for a dynamically submitted word. Any parse-able format with the definition would work fine.
Here's the example I've been working with. The function works in either script block and I have moved it around trying to get the callback to actually DO something. So far, nothing happens.
<html> <body> <script type="text/javascript" src=" http://en.wiktionary.org/w/api.php?format=json&callback=myFunc&action=opensearch&search=play "> function myFunc(str){ document.write(str); document.write("Hrm"); } </script>
<script type="text/javascript" > //myFunc("hello"); </script> </body> </html>
Thanks again, Aaron.
On Wed, Jun 9, 2010 at 4:42 PM, Roan Kattouw roan.kattouw@gmail.com wrote:
2010/6/10 Aaron Ward edugamer@gmail.com:
Alternatively, I was wondering if it might be possible to set my server
up
as a sort of proxy to go between Wiktionary and the Flash program. If I
can
use PHP, JavaScript, or HTML to query the WMF database and retrieve the desired definition, then I should be able to forward that information on
to
the game that requested it using my own cross-domain-policy.
This is probably the best solution.
Roan Kattouw (Catrope)
Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
2010/6/15 Aaron Ward edugamer@gmail.com:
<script type="text/javascript" src="http://en.wiktionary.org/w/api.php?format=json&callback=myFunc&action=opensearch&search=play"> function myFunc(str){ document.write(str); document.write("Hrm"); } </script>
I'm not sure you can mix src="" with content like that. Try using 1) separate tags for the src="" script and the myFunc() definition and 2) putting the myFunc() definition *before* the src=""
Roan Kattouw (Catrope)
Thanks Roan, that helped a bit. You were correct, the myFunc() definition had to be placed before the src. Through further research I discovered (what I believe is) the exact API call that I need for the output that I desire. However, I'm still having trouble with JavaScript accessing the returned value from the callback. At this point, I'm trying to assign the callback value to a variable and print it to the screen to confirm that I have what I'm after. So far, the only value I've been able to retrieve from the callback is: [object Object]
What I'm after is what is printed to the screen when you go to the following link: http://en.wiktionary.org/w/api.php?format=json&callback=myFunc&actio...
Does anybody see where I'm going wrong or have any suggestions?
///////////////////////////////////////////////////// <html> <body>
<script type="text/javascript" > //myFunc("hello"); function myFunc(str){ document.write(str); //var testVar = JSON.parse(str);
//document.write(testVar);
//location.href = "http://www.myURL.com/test.php?str=%22+str; } </script> <script type="text/javascript" src=" http://en.wiktionary.org/w/api.php?format=json&callback=myFunc&action=query&prop=revisions&rvprop=content&titles=play"></script>
</body> </html> /////////////////////////////////////////////////////
Thanks again, Aaron.
On Tue, Jun 15, 2010 at 3:40 AM, Roan Kattouw roan.kattouw@gmail.comwrote:
2010/6/15 Aaron Ward edugamer@gmail.com:
<script type="text/javascript" src="
http://en.wiktionary.org/w/api.php?format=json&callback=myFunc&actio... ">
function myFunc(str){ document.write(str); document.write("Hrm"); } </script>
I'm not sure you can mix src="" with content like that. Try using 1) separate tags for the src="" script and the myFunc() definition and 2) putting the myFunc() definition *before* the src=""
Roan Kattouw (Catrope)
Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
As a follow-up to my previous email, I did attempt to access the object through dot notation based on the different layers visible from the link below, but still could not figure out how to access or print anything of value.
Aaron.
On Tue, Jun 15, 2010 at 1:54 PM, Aaron Ward edugamer@gmail.com wrote:
Thanks Roan, that helped a bit. You were correct, the myFunc() definition had to be placed before the src. Through further research I discovered (what I believe is) the exact API call that I need for the output that I desire. However, I'm still having trouble with JavaScript accessing the returned value from the callback. At this point, I'm trying to assign the callback value to a variable and print it to the screen to confirm that I have what I'm after. So far, the only value I've been able to retrieve from the callback is: [object Object]
What I'm after is what is printed to the screen when you go to the following link:
http://en.wiktionary.org/w/api.php?format=json&callback=myFunc&actio...
Does anybody see where I'm going wrong or have any suggestions?
/////////////////////////////////////////////////////
<html> <body>
<script type="text/javascript" > //myFunc("hello"); function myFunc(str){ document.write(str); //var testVar = JSON.parse(str); //document.write(testVar); //location.href = "http://www.myURL.com/test.php?str="+str; } </script>
<script type="text/javascript" src=" http://en.wiktionary.org/w/api.php?format=json&callback=myFunc&action=query&prop=revisions&rvprop=content&titles=play"></script>
</body> </html> /////////////////////////////////////////////////////
Thanks again, Aaron.
On Tue, Jun 15, 2010 at 3:40 AM, Roan Kattouw roan.kattouw@gmail.comwrote:
2010/6/15 Aaron Ward edugamer@gmail.com:
<script type="text/javascript" src="
http://en.wiktionary.org/w/api.php?format=json&callback=myFunc&actio... ">
function myFunc(str){ document.write(str); document.write("Hrm"); } </script>
I'm not sure you can mix src="" with content like that. Try using 1) separate tags for the src="" script and the myFunc() definition and 2) putting the myFunc() definition *before* the src=""
Roan Kattouw (Catrope)
Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
2010/6/15 Aaron Ward edugamer@gmail.com:
As a follow-up to my previous email, I did attempt to access the object through dot notation based on the different layers visible from the link below, but still could not figure out how to access or print anything of value.
testVar is an object, yes, and assuming you're looking for the content of the revision, you need to 1) not try to parse str for JSON, it's already an object 2) add &indexpageids to your API URL and 3) access the text with str.query.pages[testVar.query.pageids[0]].revisions[0]['*'] . This assumes you didn't get an error result or a nonexistent page or whatever: in that case, this code will cause a JS error, so write code that defends against this. You can also examine the structure of the parsed JSON object in Firebug (a Firefox extension for debugging JavaScript), by placing a breakpoint inside myFunc().
Roan Kattouw (Catrope)
-----Oorspronkelijk bericht----- Van: mediawiki-api-bounces@lists.wikimedia.org namens Aaron Ward Verzonden: do 10-6-2010 1:29 Aan: MediaWiki API announcements & discussion Onderwerp: Re: [Mediawiki-api] Questions about the MediaWiki API Component
From what I've been able to find in random posts, comments, and articles
regarding Wikimedia, a universal cross-domain-policy xml does not exist on the WMF servers specifically due to a potential security risk, which is mentioned in the article QQ just linked. The author of that article also states that these security issues are limited to the specific directory where the crossdomain.xml file is located and that the developer would have to specifically call on that file to facilitate the connection. If that is true, might it be possible to setup a directory (if one doesn't already exist) where basic, read-only queries can be implemented to open up the WikiMedia content to Flash developers?
Alternatively, I was wondering if it might be possible to set my server up as a sort of proxy to go between Wiktionary and the Flash program. If I can use PHP, JavaScript, or HTML to query the WMF database and retrieve the desired definition, then I should be able to forward that information on to the game that requested it using my own cross-domain-policy.
Any thoughts would be appreciated! Aaron.
On Wed, Jun 9, 2010 at 4:05 PM, OQ overlordq@gmail.com wrote:
On Wed, Jun 9, 2010 at 3:59 PM, Roan Kattouw roan.kattouw@gmail.com wrote:
2010/6/9 Aaron Ward edugamer@gmail.com:
Am I simply using the incorrect api calls for this? Or should I be approaching this from an entirely different angle? The end goal is to
search
Wiktionary for the definition of a dynamically submitted word from
within a
Flash AS3 program, so I don't think there should be any problems with restricted information.
Yes, you're taking a totally wrong angle here. Any cross-domain restrictions are imposed by Flash or whatever it is you're using to send your HTTP requests. The API or WMF's servers have nothing to do with this: Flash or the browser or whatever is preventing your requests from ever being sent.
Actually with flash, the WMF servers do have something to do with it. Flash would require[1] a crossdomain.xml file on them to permit its access.
1 - http://www.adobe.com/devnet/flashplayer/articles/cross_domain_policy.html
Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
-----Oorspronkelijk bericht----- Van: mediawiki-api-bounces@lists.wikimedia.org namens OQ Verzonden: do 10-6-2010 1:05 Aan: MediaWiki API announcements & discussion Onderwerp: Re: [Mediawiki-api] Questions about the MediaWiki API Component
On Wed, Jun 9, 2010 at 3:59 PM, Roan Kattouw roan.kattouw@gmail.com wrote:
2010/6/9 Aaron Ward edugamer@gmail.com:
Am I simply using the incorrect api calls for this? Or should I be approaching this from an entirely different angle? The end goal is to search Wiktionary for the definition of a dynamically submitted word from within a Flash AS3 program, so I don't think there should be any problems with restricted information.
Yes, you're taking a totally wrong angle here. Any cross-domain restrictions are imposed by Flash or whatever it is you're using to send your HTTP requests. The API or WMF's servers have nothing to do with this: Flash or the browser or whatever is preventing your requests from ever being sent.
Actually with flash, the WMF servers do have something to do with it. Flash would require[1] a crossdomain.xml file on them to permit its access.
1 - http://www.adobe.com/devnet/flashplayer/articles/cross_domain_policy.html
_______________________________________________ Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
-----Oorspronkelijk bericht----- Van: mediawiki-api-bounces@lists.wikimedia.org namens Roan Kattouw Verzonden: wo 9-6-2010 22:59 Aan: MediaWiki API announcements & discussion Onderwerp: Re: [Mediawiki-api] Questions about the MediaWiki API Component
2010/6/9 Aaron Ward edugamer@gmail.com:
Am I simply using the incorrect api calls for this? Or should I be approaching this from an entirely different angle? The end goal is to search Wiktionary for the definition of a dynamically submitted word from within a Flash AS3 program, so I don't think there should be any problems with restricted information.
Yes, you're taking a totally wrong angle here. Any cross-domain restrictions are imposed by Flash or whatever it is you're using to send your HTTP requests. The API or WMF's servers have nothing to do with this: Flash or the browser or whatever is preventing your requests from ever being sent.
These cross-domain restrictions are being imposed for security reasons. I only know about the restrictions web browsers impose, where JSON callbacks allow for a 'loophole' that allows cross-domain request in a limited way but is still secure. Again, the API implements JSON callbacks so this technique can be used, but doesn't impose the restrictions that cause people to use callbacks in the first place, that's done by the browser. I'm afraid I can't help you with restrictions imposed by Flash, as I'm not familiar with them.
Roan Kattouw (Catrope)
_______________________________________________ Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
-----Oorspronkelijk bericht----- Van: mediawiki-api-bounces@lists.wikimedia.org namens Aaron Ward Verzonden: wo 9-6-2010 22:01 Aan: MediaWiki API announcements & discussion Onderwerp: Re: [Mediawiki-api] Questions about the MediaWiki API Component
Thanks for the tip Roan, but I'm afraid I'm still having trouble with this. I just spent the last couple hours researching JSON callbacks, as I have never had a need to learn about it more until now. I'm specifically trying to pull the information from within a Flash AS3 program, so I also did a bit of research about reading and decoding JSON with ActionScript 3. Unfortunately, I just appear to be spinning my wheels and not making any real progress. I'm sure I'm doing something wrong, but haven't yet been able to figure out what that is. Hopefully somebody here might be able to spot it.
Here's a link to the tutorial I'm using for using JSON with AS3, but will summarize for brevity. ( http://www.cakesgood.com/2009/04/flash-cs3-actionscript-30-json-keep-it_3277...)
We basically use Flash's net classes to request the contents at the specified URL and then decode the expected JSON response using the Adobe core library (downloadable from the tutorial). Here is the resulting ActionScript 3 code:
/////////////////////////////////////////////////////////////AS3\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ import flash.net.URLRequest; import flash.net.URLLoader; import flash.events.*; import com.adobe.serialization.json.JSON;
var loader:URLLoader = new URLLoader(); var request:URLRequest = new URLRequest();
request.url = " http://en.wiktionary.org/w/api.php?format=json&callback=myFunc&actio..." ; loader.load(request); loader.addEventListener(Event.COMPLETE, decodeJSON);
function decodeJSON(event:Event):void { trace(event.target.data); var loader:URLLoader = URLLoader(event.target); var People:Array = JSON.decode(loader.data); trace(People); } /////////////////////////////////////////////////////////////AS3\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
This results in a parse error and printing out the loader.data will display: myFunc(["play",["play"]])
I suspect this is due to an incorrect usage of the API call, but further testing and research have not produced any better results. I can't seem to get any JSON formatted call to return any contents from the page. During my research I stumbled on a collection of mediawiki-api emails where another developer (Borort) was having trouble converting XML to JSON and explained his reason for not exporting directly to JSON as: ( http://old.nabble.com/Problem-converting-new-XML-format-to-JSON-td24242786.h... )
"The reason that i don't use format=*json* is it will not return the description and url of the result.."
Roan's response to this was:
"Actually, both the *JSON* opensearch format and the XML opensearch format are documented standards, but with different fields. IIRC, the opensearch module will refuse to output anything but these two, and will output *JSON* even if you set format=php. It's only intended to be used for browser search plugins (*JSON* for Firefox, XML for IE); for other purposes, you're probably better off using list=search or list=allpages&apprefix=Foo instead.
Roan Kattouw (Catrope)"
Am I simply using the incorrect api calls for this? Or should I be approaching this from an entirely different angle? The end goal is to search Wiktionary for the definition of a dynamically submitted word from within a Flash AS3 program, so I don't think there should be any problems with restricted information.
Thanks again, Aaron.
On Wed, Jun 9, 2010 at 3:00 AM, Roan Kattouw roan.kattouw@gmail.com wrote:
2010/6/9 Aaron Ward edugamer@gmail.com:
I finally had the time to dive back into this project and managed to get everything working exactly as I was hoping.... locally! After uploading
the
game to a server it suddenly stops working again. From my knowledge with Flash games and further testing, I believe it has to do with the cross-domain-policy for Wikitionary, which is usually an xml set up on
the
server.
While attempting to locate the current Wikimedia policy I ran into random comments with warnings about the security risks involved in using the cross-domain-policy. I also discovered that Bugfix 1.9 states "Partial support for Flash cross-domain-policy filtering."
I'm not sure where to go from here. Is there a confirmed and allowed
method
to programmatically pull the rendered HTML from Wiktionary that can then
be
parsed?
You can use JSON callbacks, which basically means you (dynamically) add something like this to the HTML of your page:
<script type="text/javascript" src=" http://en.wiktionary.org/w/api.php?format=json&callback=myFunc¶metersHere "></script>
Which will cause the function myFunc() to be executed with the results of the API call passed as a parameter. However, for security reasons, all callbacks will be treated as originating from anonymous users, and they can't be used to get restricted informations, get tokens, edit stuff or anything like that.
Roan Kattouw (Catrope)
Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
2010/6/9 Aaron Ward edugamer@gmail.com:
While attempting to locate the current Wikimedia policy I ran into random comments with warnings about the security risks involved in using the cross-domain-policy. I also discovered that Bugfix 1.9 states "Partial support for Flash cross-domain-policy filtering."
Also, please note that any cross-domain policy that's blocking you is on *your client's* side, not on Wikimedia's side. We don't care where API requests come from, but clients do care where you send API requests to (same domain only in most cases).
Roan Kattouw (Catrope)
mediawiki-api@lists.wikimedia.org