In this section, we will implement a small online image search function. does it sound very high? Of course, we don't want to implement an image search engine, but we need to stand on the shoulders of giants and implement it using APIs. Our goal is to study PHP development! First, create an html page to easily implement the input and submit search functions: index.html code: Image search text search image text search: in this section we come to implement a small function of online # css/css-rwd-images.html "target =" _ blank "> Image Search, does it sound very high? Of course, we don't want to implement an image search engine, but we need to stand on the shoulders of giants and implement it using APIs. Our goal is to study PHP development!
First, create an html page to easily implement the input and submit search functions:
The index.html code is as follows:
Image search
To post data to the search. php interface, you need to implement search. php:
Data-> ResultArray; var_dump ($ result); $ url = $ result [0]-> ObjUrl; var_dump ($ url ); // jump to the image URL in the browser $ redirect = "Location :". $ url; header ($ redirect);?>
Here we call the text search API for image search. For more information, see Baidu
API stroe:http://apistore.baidu.com/apiworks/servicedetail/1557.html
Is a free API, but there is a limit on the number of calls. We only need to apply for apikey and fill in the above code to work properly.
Demo:
The above is the PHP Development entry-online image search code sharing details, please pay attention to other articles related to the first PHP community!