RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts</strong | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.69% (5.89%*) • Home Loan Fixed: 5.39% (6.59%*) • Fixed: 5.39% (6.59%*) • Variable: 5.69% (5.89%*) • Investment IO: 5.69% (6.48%*) • Investment PI: 5.39% (6.59%*)

Entertainment Quotes, Trivia, and Goofs API

Entertainment Quotes, Trivia, and Goofs API

Our social media and marketing system makes billions of images and other media available to our clients that can be immediately posted or scheduled to any number of social networks. Part of that content includes entertainment quotes, goofs, and trivia - all compiled from a number of sources. Our platform uses WordPress to query the entertainment data... and it's clumsy, cumbersome, and slow. As part of our longer-term plan of migrating the systems over to our new platform, we're moving to a very API-centric service... meaning that data will be more easily available outside of our web-based tools.

This article exists primarily for our current and former clients that have existing platform access and might choose to use the data.

The Result

The endpoint for all requests follows the following format: http://api.beliefmedia.com/platform/sources/cinema/{data-type}.json, where {data-type} is either quotes, trivia, or goofs. Required parameters for any search are type (browse, search, or show) and search (search term or show slug). An API key is required.

The first example shows a search of the quotes data for the term "friends". A request to quotes.json?apikey=xxxxx&type=search&search=friends returns JSON data that unfolds as follows:

1
Array
2
(
3
    [code] => 200
4
    [status] => 200
5
    [message] => OK
6
    [source] => BeliefMedia
7
    [data_version] => 0.2
8
    [page] => 65
9
    [number] => 3
10
    [pages] => 5013
11
    [total] => 15038
12
    [search] => Array
13
        (
14
            [type] => search
15
            [term] => friends
16
        )
17
 
18
    [results] => Array
19
        (
20
            [0] => Array
21
                (
22
                    [id] => 9gxx
23
                    [full_title] => American Playhouse (1981)
24
                    [title] => American Playhouse
25
                    [year] => 1981
26
                    [episode_name] => Who Am I This Time?
27
                    [season] => 1
28
                    [episode] => 4
29
                    [quote] => Array
30
                        (
31
                            [0] => [last lines]
32
                            [1] => [Harry is proposing to Helene, and they quote - or paraphrase - "The Importance of Being Earnest."]
33
                            [2] => Harry Nash: I've never loved anyone in the world but you.
34
                            [3] => Helene Shaw: I hope that after we marry, you'll always look at me just like this...
35
                            [4] => [They kiss passionately. Then Helene realizes that they have drawn a crowd: George, Doris, and their other friends. She laughs in embarrassment]
36
                            [5] => Helene Shaw: ...especially in front of other people!
37
                            [6] => [the others gather around, clapping and laughing]
38
                            [7] => Helene Shaw: How are you all?
39
                            [8] => George Johnson: Obviously, not as happy as you two are.
40
                            [9] => Helene Shaw: Well, George, you know, this week I've been pursued by Marc Antony, and romanced by Henry Higgins, loved by Henry the Fifth, and I was just proposed to by Ernest Worthing.
41
                            [10] => [the others laugh and clap again, with exclamations of "awww!" and the like]
42
                            [11] => Helene Shaw: Now, don't you think I'm just about the luckiest girl in town?
43
                            [12] => George Johnson: Listen, not only do I think so, but most of the women in town think so too, may I say, hmm?
44
                            [13] => [Two young ladies pass by, glaring jealously at Helene]
45
                            [14] => Helene Shaw: Well, they had their chance!
46
                            [15] => Doris: Probably most of them couldn't stand the excitement.
47
                            [16] => George Johnson: See, I don't think, I don't know if you've heard or not, but I've been asked to direct the next play.
48
                            [17] => Helene Shaw: George, that's wonderful!
49
                            [18] => George Johnson: Thank you. I, uh, I was just wondering if you two might be available for the cast?
50
                            [19] => [Harry whispers into her ear]
51
                            [20] => Helene Shaw: [grinning with delight] Who are we this time?
52
                        )
53
 
54
                    [search_slug] => american-playhouse-1981
55
                    [title_slug] => 1981/american-playhouse-1981/
56
                )
57
 
58
            [1] => Array
59
                (
60
                    [id] => XMDm
61
                    [full_title] => Anaz (2012)
62
                    [title] => Anaz
63
                    [year] => 2012
64
                    [episode_name] => Henchou
65
                    [season] => 1
66
                    [episode] => 7
67
                    [quote] => Array
68
                        (
69
                            [0] => Mei Misaki: [Kouichi walks in the hallway, Misaki appears behind him] Who's the Dead One? [Kouichi looks behind, but Mei is not there] Who's the Dead One? [Kouichi Look forward to see some friends, but he does not see Mei] Who's the Dead One? [Kouichi reaches the classroom door and opens it, his classmates are looking at him but they are immobile] Who's the Dead One? [His classmates begin to melt, as if they were statues made of wax. Scared, Kouichi flees and he finds face to face with Mei Misaki] The Dead One... is you.
70
                            [1] => Kouichi Sakakibara: Me? [Kouichi screams while he starts melting as a wax statue, he wakes up from the nightmare]
71
                        )
72
 
73
                    [search_slug] => anaz-2012
74
                    [title_slug] => 2012/anaz-2012/
75
                )
76
 
77
            [2] => Array
78
                (
79
                    [id] => rYRw
80
                    [full_title] => Anaz (2012)
81
                    [title] => Anaz
82
                    [year] => 2012
83
                    [episode_name] => Shisha
84
                    [season] => 1
85
                    [episode] => 12
86
                    [quote] => Array
87
                        (
88
                            [0] => [last lines]
89
                            [1] => Naoya Teshigawara: [Monday, August 24, 1998. Naoya is recording and storing a MD Disc with Mochizuki. While Naoya Teshigawara and Yuyya Mochizuki hide the message in the 3-3 classroom, the last lines of the message are heard]... That's how to stop the calamity. How you interpret this is up to you. Just make sure to carefully consider your actions. Think it through, and discuss it with your friends... so you'll have no regrets.
90
                        )
91
 
92
                    [search_slug] => anaz-2012
93
                    [title_slug] => 2012/anaz-2012/
94
                )
95
 
96
        )
97
 
98
)

To search a specific program, the type parameter is show and the search parameter is the show's slug (details below). So, quotes.json?apikey=xxxxx&type=show&search=friends-1994 returns JSON data that unfolds into the following array.

1
Array
2
(
3
    [code] => 200
4
    [status] => 200
5
    [message] => OK
6
    [source] => BeliefMedia
7
    [data_version] => 0.2
8
    [page] => 35
9
    [number] => 30
10
    [pages] => 59
11
    [total] => 1773
12
    [search] => Array
13
        (
14
            [type] => show
15
            [term] => friends-1994
16
        )
17
 
18
    [results] => Array
19
        (
20
            [0] => Array
21
                (
22
                    [id] => G6XY8
23
                    [full_title] => Friends (1994)
24
                    [title] => Friends
25
                    [year] => 1994
26
                    [episode_name] => The One with Joey's New Brain
27
                    [season] => 7
28
                    [episode] => 15
29
                    [quote] => Array
30
                        (
31
                            [0] => Monica Geller: Why is your family Scottish?
32
                            [1] => Chandler Bing: Why is your family, Ross?
33
                        )
34
 
35
                    [search_slug] => friends-1994
36
                    [title_slug] => 1994/friends-1994/
37
                )
38
 
39
            [1] => Array
40
                (
41
                    [id] => J6KYP
42
                    [full_title] => Friends (1994)
43
                    [title] => Friends
44
                    [year] => 1994
45
                    [episode_name] => The One with Joey's New Brain
46
                    [season] => 7
47
                    [episode] => 15
48
                    [quote] => Array
49
                        (
50
                            [0] => [Jessica is giving Joey some tips on how to play her character]
51
                            [1] => Jessica Lockhart: Well, when Jessica kisses a man, she puts her hands on the sides of his face.
52
                            [2] => Joey: [nodding] Because she's passionate?
53
                            [3] => Jessica Lockhart: No. Because that way the camera sees only her.
54
                        )
55
 
56
                    [search_slug] => friends-1994
57
                    [title_slug] => 1994/friends-1994/
58
                )
59
 
60
            [.. SNIP ..]
61
 
62
            [29] => Array
63
                (
64
                    [id] => R6BAq
65
                    [full_title] => Friends (1994)
66
                    [title] => Friends
67
                    [year] => 1994
68
                    [episode_name] =>
69
                    [season] => 0
70
                    [episode] => 0
71
                    [quote] => Array
72
                        (
73
                            [0] => Ross: [leaning over and talking to Rachel's lap] I can't wait to play with you all day, and to hear your first words.
74
                            [1] => Phoebe: [wide eyed] Why are you letting him talk to your crotch that way?
75
                            [2] => Rachel: He's talking to the baby.
76
                            [3] => Phoebe: Oh, that's good. Because when I heard, "I can't wait to hear your first words" I thought, "Boy that's some trick!"
77
                        )
78
 
79
                    [search_slug] => friends-1994
80
                    [title_slug] => 1994/friends-1994/
81
                )
82
 
83
        )
84
 
85
)

To return details for a specific episode, use quotes.json?apikey=xxxxx&id=R6BAq. Depending upon your access the returned data may return image templates to be used for image creation (the title_slug field relates to the location of a directory with show templates).

It doesn't matter if you're returning quotes, trivia, or goofs, the returned array format remains the same.

Show List

To browse available programming, the endpoint of shows.json should be used. Available parameters are page, number, and apikey (the latter is required). The returned array includes a search value that should be used (in quotes, trivia, and goof searches) to return only a specific program.

1
Array
2
(
3
    [code] => 200
4
    [status] => 200
5
    [message] => OK
6
    [source] => BeliefMedia
7
    [data_version] => 0.2
8
    [page] => 350
9
    [number] => 3
10
    [pages] => 16234
11
    [total] => 48703
12
    [data] => Array
13
        (
14
            [0] => Array
15
                (
16
                    [title] => A Shock to the System
17
                    [year] => 1990
18
                    [full_title] => A Shock to the System (1990)
19
                    [search] => a-shock-to-the-system-1990
20
                )
21
 
22
            [1] => Array
23
                (
24
                    [title] => A Short Stay in Switzerland
25
                    [year] => 2009
26
                    [full_title] => A Short Stay in Switzerland (2009)
27
                    [search] => a-short-stay-in-switzerland-2009
28
                )
29
 
30
            [2] => Array
31
                (
32
                    [title] => A Short Vision
33
                    [year] => 1956
34
                    [full_title] => A Short Vision (1956)
35
                    [search] => a-short-vision-1956
36
                )
37
 
38
        )
39
 
40
)

Sample PHP Functions

The following functions are examples only.

Search Quotes, Trivia, or Goofs

1
<?php 
2
/*
3
 Entertainment Quotes, Trivia, and Goofs API
4
 https://www.beliefmedia.com.au/entertainment-api
5
 Searches (t): quotes, trivia, goofs
6
*/
7
 
8
function beliefmedia_entertainment($t = 'quotes', $page = '', $number = '', $type = false, $search = false, $apikey = 'xxxxx') {
9
 
10
  if ($page == '') $page = '1';
11
  if ($number == '') $number = '20';
12
  if ($type === false) $type = 'browse';
13
 
14
  /* Correct for invalid 't' type */
15
  $permitted_endpoint = array('quotes', 'trivia', 'goofs');
16
  if (!in_array($t, $permitted_endpoint)) $t = 'quotes';
17
 
18
  /* Correct for invalid search type */
19
  $permitted_types = array('browse', 'search', 'show');
20
  if (!in_array($type, $permitted_types)) $type = 'browse';
21
 
22
  $type = ($type == 'browse') ? 'browse' : 'type=' . $type . '&search=' . str_replace(' ', '+', $search);
23
 
24
  $data = @file_get_contents('http://api.beliefmedia.com/platform/sources/cinema/' . $t . '.json?apikey=' . $apikey . '&pg=' . $page . '&number=' . $number . '&' . $type);
25
  if ($data === false) return false;
26
 
27
  $data = json_decode($data, true);
28
  if ($data === false) return false;
29
 
30
  /* Likely return array of errors with code & message */
31
  if ($data['code'] != '200') return $data['message'];
32
 
33
 return (array) $data;
34
}

Return List of Programs

1
<?php 
2
/*
3
 Entertainment Quotes, Trivia, and Goofs API
4
 https://www.beliefmedia.com.au/entertainment-api
5
 Searches (t): quotes, trivia, goofs
6
*/
7
 
8
function beliefmedia_entertainment_shows($page = '55', $number = '2', $apikey = 'xxxxx') {
9
 
10
  if ($page == '') $page = '1';
11
  if ($number == '') $number = '20';
12
 
13
  $data = @file_get_contents('http://api.beliefmedia.com/platform/sources/cinema/shows.json?apikey=' . $apikey . '&pg=' . $page . '&number=' . $number);
14
  if ($data === false) return false;
15
 
16
  $data = json_decode($data, true);
17
  if ($data === false) return false;
18
 
19
  /* Likely return array of errors with code & message */
20
  if ($data['code'] != '200') return $data['message'];
21
 
22
 return (array) $data;
23
}

Considerations

  • Adding &csv=yes to the request URL will return a CSV download. There are a number of other features but they're beyond the scope of this article.
  • A WordPress plugin is available to clients that will create a paginated resource in your WordPress blog. Simple Cache is required.
  • The data_version displays the current version of data. It's expected you'll cache data locally... and using the version in your transient will ensure that you always have the most up-to-date results.
  • Post on automated quotes here. In most cases moving forward, we'll be using a single blurred background image rather than a random clear image. The last point we made in that article: "we urge our partners to select appropriate material that is consistent with their brand", remains as relevant today.
  • From a social perspective, the search function permits relevant content to be sourced for sharing on various platforms. The mortgage sector, for example, might extract quotes on 'mortgages' or 'finance' and then use our image quote creation API to return a fully formatted image.

Featured Image: Ellen DeGeneres Oscar Tweet , 2nd March 2014.

■ ■ ■

 
Download our complimentary 650-page guide on marketing for mortgage brokers. We'll show you exactly how we generate billions in volume for our clients.
Finance Guide, Cropped Top and Bottom
  Timezone: 1 · [ CHANGE ]

RELATED READING

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

Leave a comment