-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_Post.php
More file actions
75 lines (66 loc) · 2.65 KB
/
create_Post.php
File metadata and controls
75 lines (66 loc) · 2.65 KB
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
66
67
68
69
70
71
72
73
74
75
<?php require 'header.php';
require 'nav.php';
require 'db_key.php';
$NAME = $_GET["song"];
$songID = $_SESSION['songID'];
$_SESSION['song'] = $NAME;
?>
<body>
<br>
<div class='container'>
<div class='row'>
<div card ="col-lg-7">
<div class='card mb-4'>
<div class='card-body'>
<h1> Create A Post </h1>
<div class='card mb-4'>
<div class='card-body'>
<form action="backend.php" method="POST" enctype="multipart/form-data">
<div class="form-group">
<label for="spotSearch" card="card-title">Search for a Song on Spotify:</label>
<input class="form-control" id="spotSearch" type="text" name="searchSong">
</div>
<sp> <button type="submit" name="searchbtnsong" value="searchbtn" class="searchbtnsong">Search</button> <br> <br>
</form>
<?php
if($_GET){
echo"<div class ='card mx-auto'>";
echo "<div class ='card-body'>";
echo "<p class='card-title'> Spotify Search Results </p>";
require 'vendor/autoload.php';
$session = new SpotifyWebAPI\Session(
'b7d9baca79b6424597551d19d5fd02cf',
'6b988bb0c7ae4cf58013ff29e6ce5a26',
'https://login490.herokuapp.com/redir.php'
);
$api = new SpotifyWebAPI\SpotifyWebAPI();
$session->requestCredentialsToken();
$accessToken = $session->getAccessToken();
// Set the code on the API wrapper
$api->setAccessToken($accessToken);
//echo "<p>" . $accessToken . "</p>";
$res = $api->search($_SESSION["song"], ['track']);
foreach($res->tracks->items as $track){
echo "<a href='songredir.php?id=". $track->id . "'>" . $track->name . $track->artist . "</a>" . '<br>';
}
echo "</div>";
echo "</div>";
}
?>
<form action="backend.php" method="POST" enctype="multipart/form-data">
<div class='form-group'>
<label for="img">Attach image:</label><br>
<input type="file" id="img" name="img" accept="image/*"> <br><br>
<textarea class="form-control" name="post_Text" placeholder="Write your post here!"></textarea>
<button class="btn btn-outline-info" type="submit" name="create_Post" value="Post">Post</button> <br>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
</body></html>