DigitalVeer

somewhat complete api

Dec 5th, 2015
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.72 KB | None | 0 0
  1. <?php
  2.      require 'simple_html_dom.php';
  3.     include 'group.php';
  4.  
  5.         function GetMyID(){
  6.                 $second_response = Send("http://www.roblox.com/Game/GetCurrentUser.ashx");
  7.                 return $second_response;
  8.         }
  9.  
  10.         function GetMyUsername(){
  11.                 $id = GetMyID();
  12.                 $fourth_response = Send("http://api.roblox.com/Users/$id");
  13.                 $user = json_decode($fourth_response);
  14.                 $actualuser = $user->{"Username"};
  15.                 return $actualuser;
  16.         }
  17.        
  18.        
  19.         function getUsername($id){
  20.                 $user_response = Send("http://api.roblox.com/Users/$id");
  21.                 $user = json_decode($user_response);
  22.                 return $user->{"Username"}?  $user->{"Username"} : "yea um.. that id dosent exist";
  23.         }
  24.        
  25.         function getID($user){
  26.             $id_response = Send("http://api.roblox.com/users/get-by-username?username=$user");
  27.             $actual_id = json_decode($id_response);
  28.             return $actual_id->{"Id"}?  $actual_id->{"Id"} : "yea um.. that username dosent exist";
  29.         }
  30.        
  31.         function getRecUser($user){
  32.         return Send("http://www.roblox.com/UserCheck/GetRecommendedUsername?usernameToTry=$user");
  33.         }
  34.        
  35.         class docScanner extends simple_html_dom {
  36.             function isOnline($id){
  37.                 $player_response = Send("http://www.roblox.com/User.aspx?ID=$id");
  38.                 $htmlDom = $this->load($player_response);
  39.                 $onlineStatus = $htmlDom->getElementById('profile-about-content-text');
  40.                 if(strpos($player_response,"UserOnlineMessage") != False or strpos($player_response, "ctl00_cphRoblox_rbxUserPane_UserOnlineStatusHyperLink") != False){
  41.                     return "Online";
  42.                 } else {
  43.                     return "Offline";
  44.             }
  45.         }
  46.        
  47.        
  48.    
  49. }
  50.    
  51. switch($_REQUEST["action"])
  52.     {  
  53.     case "getIdFromUser":
  54.     echo ($_REQUEST["userValue"] != null)? getId($_REQUEST["userValue"]) : "Error! No UserId Provided!";
  55.     break;
  56.     case "getUserFromId":
  57.     echo getUsername($_REQUEST["plrId"]);
  58.     break;
  59.     case "getRecommendedUserName":
  60.     echo getRecUser($_REQUEST["suggesteduser"]);
  61.     break;
  62.     case "getMyUser":
  63.     echo GetMyUsername();
  64.     break;
  65.     case "getMyId":
  66.     echo GetMyID();
  67.     break;
  68.     case "checkOnline":
  69.     $scann = new docScanner();
  70.     echo $scann->isOnline($_REQUEST["plrId"]);
  71.     break;
  72.     case "setRank":
  73.         if(!isset($_REQUEST["userId"]))
  74.             die("Error: No user id!");
  75.         $userId = $_REQUEST["userId"];
  76.        
  77.         if(!isset($_REQUEST["groupId"]))
  78.             die("Error: No group id!");
  79.         $groupId = $_REQUEST["groupId"];
  80.        
  81.         if(isset($_REQUEST["rankId"]))
  82.         {
  83.             $rankId = $_REQUEST["rankId"];
  84.             $rankValue = GetRankValueFromRankId($groupId,$_REQUEST["rankId"]);
  85.         }
  86.         elseif(isset($_REQUEST["rankValue"]))
  87.         {
  88.             $rankId = GetRankIdFromRankValue($groupId,$_REQUEST["rankValue"]);
  89.             $rankValue = $_REQUEST["rankValue"];
  90.         }
  91.         elseif(isset($_REQUEST["rankTitle"]))
  92.         {
  93.             $rankId = GetRankIdFromRankValue($groupId,$_REQUEST["rankTitle"]);
  94.             $rankValue = GetRankValueFromRankTitle($_REQUEST["rankTitle"]);
  95.         }
  96.         else
  97.             die("Error: No rank specified!");
  98.            
  99.         if( $rankId == null || $rankValue == null )
  100.             die("Error: No such rank!");
  101.            
  102.         $currentUserRank = GetUserRankInGroup($groupId,$userId);
  103.         if( $currentUserRank == 0 )
  104.             die("Error: Not in group!");
  105.        
  106.         if( $rankValue == $currentUserRank )
  107.             die("Error: Already that rank!");
  108.         elseif( $rankValue < $currentUserRank )
  109.             if( isset($_REQUEST["force"]) && $_REQUEST["force"] == "true" )
  110.                 if ( ChangeRank($groupId,$rankId,$userId) )
  111.                     die("Ok: Demoted");
  112.                 else
  113.                     die("Error: Unknow (login maybe)");
  114.             else
  115.                 die("Error: Demotes needs to be forced!");
  116.         else
  117.             if ( ChangeRank($groupId,$rankId,$userId) )
  118.                 die("Ok: Promoted");
  119.             else
  120.                 die("Error: Unknow (login maybe)");
  121.         break; 
  122.     }
  123.    
  124.    
  125. ?>
Advertisement
Add Comment
Please, Sign In to add comment