Skip to content
Extraits de code Groupes Projets
Valider 3982de2f rédigé par Kevin XU's avatar Kevin XU
Parcourir les fichiers

Ajout page profil youtube

parent a08697df
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -7,7 +7,7 @@ $res = [];
for ($i=0; $i<5; $i++){
$res[$i]['username'] = $results[$i]->screen_name;
$res[$i]['profile_image'] = $results[$i]->profile_image_url;
$res[$i]['id'] = $results[$i]->id;
}
echo json_encode($res);
......
......@@ -9,6 +9,14 @@
document.getElementById('usernames').innerHTML = "";
return;
}
var socialNetwork = "Twitter";
if (document.getElementById("radio_3").checked == true) {
socialNetwork = "Twitter";
}
else if (document.getElementById("radio_2").checked == true) {
socialNetwork = "Youtube";
}
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {// 4 = request finished and response is ready, 200 = "OK"
......@@ -18,7 +26,7 @@
var options = "";
for(var i = 0; i < tab.length; i++) {
options += '<button id="userSuggesBtn" class="suggestionButton" onclick="window.location.href=\'../page_profile/profil.php?username='+tab[i].username+'\'"><img src="'+
options += '<button id="userSuggesBtn" class="suggestionButton" onclick="window.location.href=\'../page_profile/profil.php?id='+tab[i].id+'&sn='+socialNetwork+'\'"><img src="'+
tab[i].profile_image +
'" alt="icone" style="vertical-align:middle; position:relative; width:50px; height: 50px;" /><span style="margin-left:10px;">'+
tab[i].username +
......@@ -34,7 +42,7 @@
API = "API_Twitter";
}
else if (document.getElementById("radio_2").checked == true) {
API = "youtube-api"
API = "youtube-api";
}
else {
document.getElementById("erreur").innerHTML = "Please select a social network.";
......
<?php
require_once('../API_Twitter/userInfosFunctions.php');
require_once('../youtube-api/userInfos.php');
require_once('../facto.php');
session_start();
......@@ -12,6 +13,22 @@ elseif (isset($_POST['id'])) {
elseif (isset($_GET['username'])) {
$id = getUserId($_GET['username']);
}
elseif (isset($_GET['id'])) {
$id = $_GET['id'];
}
else {
echo('ERREUR');
}
if (isset($_POST['sn'])) {
$socialNetwork = $_POST['sn'];
}
elseif (isset($_POST['sn'])) {
$socialNetwork = $_POST['sn'];
}
elseif (isset($_GET['sn'])) {
$socialNetwork = $_GET['sn'];
}
else {
echo('ERREUR');
}
......@@ -38,14 +55,40 @@ else {
-->
<div id="photoprofil">
<img src='<?php echo getUserProfileImage($id) ?>' alt='profile_image' style="width:100px;height:100px;"/>
<img src='<?php
if ($socialNetwork === "Twitter") {
echo getUserProfileImage($id);
}
elseif ($socialNetwork === "Youtube") {
echo getChannelProfileImage($id);
}
?>' alt='profile_image' style="width:100px;height:100px;"/>
</div>
<br/><br/>
<div class='flexspace' style="padding:30px 40px 0px;border-left:1px solid;width:100%;background-image: linear-gradient(to bottom right, #919df9, #93eeff);border-radius:50px">
<div>Twitter Username <br/> <h5><?php echo getUserScreenName($id) ?></h5><br/></div>
<div>Twitter Followers <br/> <h5><?php echo number_format (getUserNbFollowers($id), 0, ".", " ")?></h5><br/></div>
<div>Ville ?<br/> <h5></h5> </div>
<div>autre ?<br/> <h5></h5></div>
<div><?php echo $socialNetwork; ?> Username <br/> <h5><?php
if ($socialNetwork === "Twitter") {
echo getUserScreenName($id);
}
elseif ($socialNetwork === "Youtube") {
echo getChannelUsername($id);
}
?>
</h5><br/></div>
<div>
<?php
if ($socialNetwork === "Twitter") {
echo "Twitter Followers <br/> <h5>".number_format(getUserNbFollowers($id), 0, ".", " ");
}
elseif ($socialNetwork === "Youtube") {
echo "Youtube Subscribers <br/> <h5>".number_format(getChannelNbFollowers($id), 0, ".", " ");
}
?>
</h5><br/>
</div>
<div> <br/> <h5></h5> </div>
<div> <br/> <h5></h5></div>
</div>
</div>
......
......@@ -26,6 +26,13 @@ function getChannelId($id){
return $res;
}
function getChannelUsername($id){
global $setting;
$youtube = new Madcoda\Youtube\Youtube($setting);
$res= $youtube->getChannelById($id);
return $res->snippet->title;
}
function getChannelNbFollowers($id) {
global $setting;
$youtube = new Madcoda\Youtube\Youtube($setting);
......@@ -37,7 +44,7 @@ function getChannelProfileImage($id) {
global $setting;
$youtube = new Madcoda\Youtube\Youtube($setting);
$res= $youtube->getChannelById($id);
$url = $res->thumbnails->medium->url;
$url = $res->snippet->thumbnails->high->url;
return $url;
}
......@@ -54,3 +61,4 @@ function getChannelViewCount($id) {
$res= $youtube->getChannelById($id);
return intval($res->statistics->viewCount);
}
<?php
require './userInfos.php';
$results = searchByKey($_GET['w']);
$res=array();
for ($i=0; $i<5; $i++){
$res[$i]['username'] = $results[$i]->snippet->channelTitle;
$res[$i]['profile_image'] = $results[$i]->snippet->thumbnails->default->url;
$res[$i]['id'] = $results[$i]->snippet->channelId;
}
echo json_encode($res);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter