-
Notifications
You must be signed in to change notification settings - Fork 0
/
showimg.php
65 lines (56 loc) · 1.37 KB
/
showimg.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* Ajax Image Handler
*
* @author Michael Berneis
*
*/
require_once "config.php";
$locales = array(
'ar' => 'ar-XA',
'bg' => 'bg-BG',
'cs' => 'cs-CZ',
'da' => 'da-DK',
'nl' => 'nl-NL',
'en' => 'en-US',
'et' => 'et-EE',
'fi' => 'fi-FI',
'fr' => 'fr-FR',
'de' => 'de-DE',
'el' => 'el-GR',
'he' => 'he-IL',
'hu' => 'hu-HU',
'it' => 'it-IT',
'ja' => 'ja-JP',
'ko' => 'ko-KR',
'lv' => 'lv-LV',
'lt' => 'lt-LT',
'no' => 'nb-NO',
'pl' => 'pl-PL',
'pt' => 'pt-PT',
'ro' => 'ro-RO',
'ru' => 'ru-RU',
'sk' => 'sk-SK',
'sl' => 'sl-SL',
'es' => 'es-ES',
'sv' => 'sv-SE',
'th' => 'th-TH',
'tr' => 'tr-TR',
'uk' => 'uk-UA'
);
$locale= $locales[$_GET['locale']];
$term = $_GET['term'];
$cred = sprintf( 'Authorization: Basic %s', base64_encode( "ignored:" . $AccountKey ) );
$context = stream_context_create( array(
'http' => array(
'header' => $cred
)
) );
$request ='https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&Query=%27'.urlencode( $term ).'%27&Market=%27'.urlencode( $locale ).'%27';
$response = file_get_contents( $request, 0, $context );
$jsonobj = json_decode( $response );
foreach ( $jsonobj->d->results as $value ) {
$url = $value->SourceUrl;
$pic = $value->Thumbnail->MediaUrl;
print "<div><a href='$url' target='_blank'><img style='width:100%' src='".$pic."' /></a></div>";
}