diff --git a/js/recherche.js b/js/recherche.js index 8797961c554b85aaa0edddac76fb3a94348935f9..b499c5478f08c94af9fae7d7e74d5f38f0ca41fe 100644 --- a/js/recherche.js +++ b/js/recherche.js @@ -28,7 +28,15 @@ document.getElementById('suggestionButtons').innerHTML = options; } }; - xhttp.open("GET", "../API_Twitter/userSuggestions.php?w="+keyword, true); + + var API = "API_Twitter"; + if (document.getElementById("radio_3").checked == true) { + API = "API_Twitter"; + } + else if (document.getElementById("radio_2").checked == true) { + API = "youtube-api" + } + xhttp.open("GET", "../"+API+"/userSuggestions.php?w="+keyword, true); xhttp.send(); } </script> diff --git a/page_welcome/index.php b/page_welcome/index.php index 228ed8df330beb5c58768d91e606851568988f8e..ac2cbb143990f9ce6e144bd6f6f36443e897bf89 100644 --- a/page_welcome/index.php +++ b/page_welcome/index.php @@ -36,16 +36,16 @@ session_start(); <!-- <input type="submit" value="Search"> --> <div style="display: inline-flex;"> - <input class="img" type="radio" id="radio_1" name="radio[]" value="1" /> + <input class="img" type="radio" id="radio_1" name="radio[]" value="1" onchange="showSuggestions();"/> <label for="radio_1"><img src="../images/ins.png" width="50" height="50"/></label> - <input class="img" type="radio" id="radio_2" name="radio[]" value="2" /> + <input class="img" type="radio" id="radio_2" name="radio[]" value="2" onchange="showSuggestions();"/> <label for="radio_2"><img src="../images/youtube.jpeg" width="50" height="50"/></label> - <input class="img" type="radio" id="radio_3" name="radio[]" value="3" /> + <input class="img" type="radio" id="radio_3" name="radio[]" value="3" onchange="showSuggestions();"/> <label for="radio_3"><img src="../images/twitter.png" width="50" height="50"/></label> - <input class="img" type="radio" id="radio_4" name="radio[]" value="4" /> + <input class="img" type="radio" id="radio_4" name="radio[]" value="4" onchange="showSuggestions();"/> <label for="radio_4"><img src="../images/facebook.png" width="50" height="50"/></label> </div> <input id="searchField" style="height: 50px; font-size: 20px;" list="usernames" name="username" type="text" size="40" maxlength="100" autocomplete="off" placeholder="Search here..." onkeyup=" diff --git a/youtube-api/userSuggestions.php b/youtube-api/userSuggestions.php index dc7a30d9ebff4b967b801e9c410328560b4de36e..e38473c7b4e7044a14c79b71d28384a0676cb2b0 100644 --- a/youtube-api/userSuggestions.php +++ b/youtube-api/userSuggestions.php @@ -2,13 +2,13 @@ require './userInfos.php'; -$results = searchByKey($_GET['key']); +$results = searchByKey($_GET['w']); $res=array(); for ($i=0; $i<5; $i++){ - $res[$i]['channelTitle'] = $results[$i]->snippet->channelTitle; + $res[$i]['username'] = $results[$i]->snippet->channelTitle; $res[$i]['profile_image'] = $results[$i]->snippet->thumbnails->default->url; }