diff --git a/user/profile/index.php b/user/profile/index.php index 29f542f..fc8b0af 100644 --- a/user/profile/index.php +++ b/user/profile/index.php @@ -77,6 +77,21 @@ header('Content-Type: application/json'); echo '{"code": 420, "data": "", "success": false, "error": "Please try again later."}'; } +$stmt->close(); +} else if (isset($put['avatarUrl'])) { +$avatarUrl = $put['avatarUrl']; +// Prepare the SQL query to update account +$sql = "UPDATE accounts SET picture = ? WHERE SID = ?"; +$stmt = $conn->prepare($sql); +$stmt->bind_param("ss", $avatarUrl, $sid); +if ($stmt->execute() === TRUE) { +echo '{"code": "", "data": {}, "success": true, "error": ""}'; +} else { +header('HTTP/1.1 500 Internal Server Error'); +header('Content-Type: application/json'); +echo '{"code": 420, "data": "", "success": false, "error": "Please try again later."}'; +} + $stmt->close(); } else { echo '{"code": "", "data": {}, "success": true, "error": ""}'; diff --git a/user/profile/profile.php b/user/profile/profile.php new file mode 100644 index 0000000..cf8bac2 --- /dev/null +++ b/user/profile/profile.php @@ -0,0 +1,68 @@ +connect_error) { +header('HTTP/1.1 500 Internal Server Error'); +header('Content-Type: application/json'); +echo '{"code": 420, "data": "", "success": false, "error": "Please try again later."}'; +die(""); +} +?> +prepare($sql); +$stmt->bind_param("s", $vine_id); + +// Execute the statement +$stmt->execute(); + +// Get the result +$result = $stmt->get_result(); + +// Check if any rows were returned +if ($result->num_rows > 0) { +// Output data of each row +while($row = $result->fetch_assoc()) { +if ($row["description"] == NULL) { +$description = "null"; +} else { +$description = '"' . $row["description"] . '"'; +} + +if ($row["location"] == NULL) { +$location = "null"; +} else { +$location = '"' . $row["location"] . '"'; +} + +if ($row["picture"] == NULL) { +$picture = "null"; +} else { +$picture = '"' . $row["picture"] . '"'; +} +header('Content-Type: application/json'); +echo '{"code": "", "data": {"username": "' . $row['username'] . '", "profileBackground": "' . $row['color'] . '", "followerCount": ' . $row['followersc'] . ', "verified": ' . $row['verified'] . ', "vanityUrls": [], "loopCount": ' . $row['loopc'] . ', "avatarUrl": ' . $picture . ', "authoredPostCount": 22, "shareUrl": "https://vine.co/u/' . $row['id'] . '", "userId": ' . $row['id'] . ', "private": 0, "likeCount": ' . $row['likec'] . ', "postCount": ' . $row['postc'] . ', "location": ' . $location . ', "followingCount": ' . $row['followingc'] . ', "explicitContent": 0, "description": ' . $description . '}, "success": true, "error": ""}'; +} +} else { +header('HTTP/1.1 404 Not Found'); +header('Content-Type: application/json'); +echo '{"code": 115, "data": "", "success": false, "error": "User id is not valid"}'; +} + +// Close the statement and connection +$stmt->close(); +$conn->close(); +?> \ No newline at end of file