Created
June 27, 2019 12:22
-
-
Save ennjoy/41f639f016b4935af5772f077ea4c53b to your computer and use it in GitHub Desktop.
json.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$screen_name = isset($_REQUEST['screen_name']) ? secure($_REQUEST['screen_name']) : false; | |
$access_token = check_token(); | |
if ($screen_name) { | |
$row_screen_name = mysqli_fetch_assoc(mysqli_query($sqlConnect, "SELECT user_id FROM ". T_USERS ." WHERE username = '$screen_name' LIMIT 1 ")); | |
$type = 'user'; | |
$object_id = $row_screen_name['user_id']; | |
} | |
if ($row_screen_name == null) { | |
$row_screen_name = mysqli_fetch_assoc(mysqli_query($sqlConnect, "SELECT page_id FROM ". T_PAGES ." WHERE page_name = '$screen_name' LIMIT 1 ")); | |
$type = 'page'; | |
$object_id = $row_screen_name['page_id']; | |
} | |
if ($row_screen_name == null) { | |
$row_screen_name = mysqli_fetch_assoc(mysqli_query($sqlConnect, "SELECT id FROM ". T_GROUPS ." WHERE group_name = '$screen_name' LIMIT 1 ")); | |
$type = 'group'; | |
$object_id = $row_screen_name['id']; | |
} | |
if (!$screen_name) { | |
error(2, 'not found screen_name'); | |
} | |
if (!$row_screen_name) { | |
error(3, 'screen_name - '.$screen_name.' is incorrect'); | |
} | |
if (!empty($type)) { | |
$result['type'] = $type; | |
} | |
if (!empty($object_id)) { | |
$result['object_id'] = $object_id; | |
} | |
$response = array( | |
'response' => $result | |
); | |
json_encode_cyr($response); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment