Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 836613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:00:44+00:00 2026-05-15T05:00:44+00:00

I’m developing a program whose background image will change in relation to the trending

  • 0

I’m developing a program whose background image will change in relation to the trending topics of twitter. So I have a function which returns me a word (first TT on twitter), then I need another function that will give me a url of an image relative to that word, like Google image search or flickr.

Do you know how to do this? or even better, do you have a php script made?

In summary: is there a function that will do a google image or flickr search, and return a corresponding url to an image for the word

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T05:00:45+00:00Added an answer on May 15, 2026 at 5:00 am

    Google’s AJAX Search API allows you to search for images: Video and Image Search Examples, though whether you could use PHP to parse the results I’m not sure. You could certainly parse the returned data to extract image urls to apply as backgrounds though. There is also a Yahoo Image Search API and flickr Search API to try.

    The Google AJAX Documentation has a PHP code snippet that shows how to call searches using PHP.

    Here’s code that finds image search results for “batman”:

    $word = "batman";
    $manual_referer = 'http://example.com/';
    
    // See reference for how to modify search
    // http://code.google.com/apis/ajaxsearch/documentation/reference.html
    $args = array(
        'v' => '1.0',
        'q' => $word,
        'as_filetype' => 'jpg',
        'imgsz' => 'medium', // image size
        'safe' => 'active', // image "safeness"
        'as_filetype' => 'jpg',
    );
    $url = "http://ajax.googleapis.com/ajax/services/search/images?";
    foreach ($args as $key => $val) {
        $url .= $key . '=' . rawurlencode($val) . '&';
    }
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_REFERER, $manual_referer);
    $body = curl_exec($ch);
    curl_close($ch);
    
    $json = json_decode($body, true);
    $results = $json['responseData']['results'];
    foreach ($results as $result) {
        print "<img src=";
        print $result['url']; // here's your url
        print ">";
    }
    

    Here’s what the raw returned json looks like when decoded:

    Array
    (
        [responseData] => Array
            (
                [results] => Array
                    (
                        [0] => Array
                            (
                                [GsearchResultClass] => GimageSearch
                                [width] => 240
                                [height] => 338
                                [imageId] => k8FYqFKsdhvu3M:
                                [tbWidth] => 84
                                [tbHeight] => 119
                                [unescapedUrl] => http://lizilla.files.wordpress.com/2009/08/batman.jpg
                                [url] => http://lizilla.files.wordpress.com/2009/08/batman.jpg
                                [visibleUrl] => lizilla.wordpress.com
                                [title] => Superhero&#39;s, Animation, Comics, And Interesting Movies. « Lizilla
                                [titleNoFormatting] => Superhero&#39;s, Animation, Comics, And Interesting Movies. « Lizilla
                                [originalContextUrl] => http://lizilla.wordpress.com/2009/08/26/superheros-animation-comics-and-interesting-movies/
                                [content] => Dunanununanuna <b>BATMAN</b>!
                                [contentNoFormatting] => Dunanununanuna BATMAN!
                                [tbUrl] => http://images.google.com/images?q=tbn:k8FYqFKsdhvu3M::lizilla.files.wordpress.com/2009/08/batman.jpg
                            )
    
                        [1] => Array
                            (
                                [GsearchResultClass] => GimageSearch
                                [width] => 307
                                [height] => 290
                                [imageId] => faxJ90Dbo1TW1M:
                                [tbWidth] => 117
                                [tbHeight] => 111
                                [unescapedUrl] => http://www.solarnavigator.net/films_movies_actors/film_images/batman_michael_keaton_jack_nocholson_joker_marvel_comics.jpg
                                [url] => http://www.solarnavigator.net/films_movies_actors/film_images/batman_michael_keaton_jack_nocholson_joker_marvel_comics.jpg
                                [visibleUrl] => www.solarnavigator.net
                                [title] => <b>BATMAN</b> THE MOVIE
                                [titleNoFormatting] => BATMAN THE MOVIE
                                [originalContextUrl] => http://www.solarnavigator.net/films_movies_actors/batman.htm
                                [content] => <b>Batman</b> and the Joker in the
                                [contentNoFormatting] => Batman and the Joker in the
                                [tbUrl] => http://images.google.com/images?q=tbn:faxJ90Dbo1TW1M::www.solarnavigator.net/films_movies_actors/film_images/batman_michael_keaton_jack_nocholson_joker_marvel_comics.jpg
                            )
    
                        [2] => Array
                            (
                                [GsearchResultClass] => GimageSearch
                                [width] => 300
                                [height] => 300
                                [imageId] => nDWzhPnraNi_gM:
                                [tbWidth] => 116
                                [tbHeight] => 116
                                [unescapedUrl] => http://i192.photobucket.com/albums/z167/Great_WhiteSnark/batman_bale-1.jpg
                                [url] => http://i192.photobucket.com/albums/z167/Great_WhiteSnark/batman_bale-1.jpg
                                [visibleUrl] => www.coolchaser.com
                                [title] => <b>batman</b> MySpace graphics and comments
                                [titleNoFormatting] => batman MySpace graphics and comments
                                [originalContextUrl] => http://www.coolchaser.com/graphics/tag/batman
                                [content] => All Graphics » <b>batman</b>
                                [contentNoFormatting] => All Graphics » batman
                                [tbUrl] => http://images.google.com/images?q=tbn:nDWzhPnraNi_gM::i192.photobucket.com/albums/z167/Great_WhiteSnark/batman_bale-1.jpg
                            )
    
                        [3] => Array
                            (
                                [GsearchResultClass] => GimageSearch
                                [width] => 250
                                [height] => 302
                                [imageId] => W9EAV1DUDesHuM:
                                [tbWidth] => 96
                                [tbHeight] => 116
                                [unescapedUrl] => http://upload.wikimedia.org/wikipedia/en/thumb/f/f6/New_Batman_Adventures_cast.jpg/250px-New_Batman_Adventures_cast.jpg
                                [url] => http://upload.wikimedia.org/wikipedia/en/thumb/f/f6/New_Batman_Adventures_cast.jpg/250px-New_Batman_Adventures_cast.jpg
                                [visibleUrl] => en.wikipedia.org
                                [title] => The New <b>Batman</b> Adventures - Wikipedia, the free encyclopedia
                                [titleNoFormatting] => The New Batman Adventures - Wikipedia, the free encyclopedia
                                [originalContextUrl] => http://en.wikipedia.org/wiki/The_New_Batman_Adventures
                                [content] => The New <b>Batman</b> Adventures
                                [contentNoFormatting] => The New Batman Adventures
                                [tbUrl] => http://images.google.com/images?q=tbn:W9EAV1DUDesHuM::upload.wikimedia.org/wikipedia/en/thumb/f/f6/New_Batman_Adventures_cast.jpg/250px-New_Batman_Adventures_cast.jpg
                            )
    
                    )
    
                [cursor] => Array
                    (
                        [pages] => Array
                            (
                                [0] => Array
                                    (
                                        [start] => 0
                                        [label] => 1
                                    )
    
                                [1] => Array
                                    (
                                        [start] => 4
                                        [label] => 2
                                    )
    
                                [2] => Array
                                    (
                                        [start] => 8
                                        [label] => 3
                                    )
    
                                [3] => Array
                                    (
                                        [start] => 12
                                        [label] => 4
                                    )
    
                                [4] => Array
                                    (
                                        [start] => 16
                                        [label] => 5
                                    )
    
                                [5] => Array
                                    (
                                        [start] => 20
                                        [label] => 6
                                    )
    
                                [6] => Array
                                    (
                                        [start] => 24
                                        [label] => 7
                                    )
    
                                [7] => Array
                                    (
                                        [start] => 28
                                        [label] => 8
                                    )
    
                            )
    
                        [estimatedResultCount] => 3050000
                        [currentPageIndex] => 0
                        [moreResultsUrl] => http://www.google.com/images?oe=utf8&ie=utf8&source=uds&start=0&safe=active&imgsz=medium&as_filetype=jpg&hl=en&q=batman
                    )
    
            )
    
        [responseDetails] => 
        [responseStatus] => 200
    )
    

    A tricky aspect of this is that you may need permission to use these images. In some testing it looks like when you restrict by public domain you get far fewer images in result. Also, there’s no mechanism to restrict to servers that are actually available at that time, so sometimes you may get a valid url but no image will be available. It seems like a simple request, but it introduces other issues in url handling.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 480k
  • Answers 480k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can retrieve the line number from the InvocationInfo object… May 16, 2026 at 6:08 am
  • Editorial Team
    Editorial Team added an answer EDIT Since you're already using the XML parser, you're guaranteed… May 16, 2026 at 6:08 am
  • Editorial Team
    Editorial Team added an answer EDIT: Note that if you're not concerned about IE6 support,… May 16, 2026 at 6:08 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.