چرت و پرت های یک برنامه نویس

اینجا جاییه که خودم مینویسم. شاید به دردتون بخوره ، شایدم نه... به من ربطی نداره

طبقه بندی موضوعی
نویسندگان

imdb api for other websites

دوشنبه, ۲ آذر ۱۳۹۴، ۰۱:۲۸ ب.ظ

The IMDb currently has two public APIs that are, although undocumented, very quick and reliable (used on their own site through AJAX).

  1. A statically cached search suggestions API:

    • http://sg.media-imdb.com/suggests/a/aa.json
    • http://sg.media-imdb.com/suggests/h/hello.json
    • Format: JSONP
    • Downside:

      • It's in JSONP format, however the callback parameter can not be set by passing a callback-query parameter. In order to use it cross-domain you'll have to use the function name they choose (which is in the "imdb${searchphrase}" format, see example below). Or use a local proxy (e.g. a small php file) that downloads (and caches!) it from IMDb and strips the JSON-P callback, or replaces it with a custom callback.

      • If there are no results, it doesn't gracefully fallback, but displays an XML error instead

// Basic
window.imdb$foo = function (list) {
  /* ... */
};
jQuery.getScript('http://sg.media-imdb.com/suggests/f/foo.json');

// Using jQuery.ajax (let jQuery handle the callback)
jQuery.ajax({
    url: 'http://sg.media-imdb.com/suggests/f/foo.json',
    dataType: 'jsonp',
    cache: true,
    jsonp: false,
    jsonpCallback: 'imdb$foo'
}).done(function (result) {
    /* ... */
});

// With local proxy to a PHP script replacing imdb$foo with a sanitized
// version of $_GET['callback'] (http://stackoverflow.com/a/8811412/319266)
jQuery.getJSON('./imdb.php?q=foo&callback=?', function (list) {
    /* ... */
});
  1. More advanced search

As said, both of these APIs are undocumented. They could change at any time.

See also http://stackoverflow.com/a/8811412/319266, for an example of a JSON API in PHP.


  • حمید حق دوست

نظرات  (۰)

هیچ نظری هنوز ثبت نشده است
ارسال نظر آزاد است، اما اگر قبلا در بیان ثبت نام کرده اید می توانید ابتدا وارد شوید.
شما میتوانید از این تگهای html استفاده کنید:
<b> یا <strong>، <em> یا <i>، <u>، <strike> یا <s>، <sup>، <sub>، <blockquote>، <code>، <pre>، <hr>، <br>، <p>، <a href="" title="">، <span style="">، <div align="">
تجدید کد امنیتی