Applications written as Java applets, Flash or Javascript widgets often face security issues where they cannot talk to a data source which does not have the same domain name as the one where they get served from. For example, if you are going to host a flash widget on http://example.com, your flash securtiy settings will normally not let you talk to any data source that is not hosted on http://example.com.
There are workarounds using crossdomain files to solve someo of these problems. However, we do not support a crossdomain file for our freeapi.daylife.com domain that lets your widget read data from anywhere.
To work-around these security issues, you need a proxy that you can host on the same domain as your widget and that proxies all DayPI calls.
Read more below to learn how to use this proxy. The attached code in PHP has the following features:
you provide the following value to the request parameter:
request=%2Fxmlrest%2Fpublicapi%2F4.2%2Fsearch_getRelatedArticles%3Fquery%3DBarack%2520Obama%26
accesskey%3D8befa1cf0a7c0291613242235638a662%26signature%3D82a0ad71c7180a36530c9f59daea6617
Idea is to take the portion of the DayPI URL beyond the domain name http://freaapi.daylife.com/ and urlencode it. If you host this PHP file in the document root of your server (say http://example.com), your widget will make the API call using the proxy as follows:
http://example.com/proxy.php?request=%2Fxmlrest%2Fpublicapi%2F4.2%2Fsearch_getRelatedArticles%3F
query%3DBarack%2520Obama%26accesskey%3D8befa1cf0a7c0291613242235638a662%26signature%3D82a0ad71c7180a36530c9f59daea6617
=function) wraps the JSON output text in parentheses and a function name of your choosing.
| Attachment | Size |
|---|---|
| proxy.zip | 1.07 KB |