| <!DOCTYPE html>
|
| <html>
|
| <head>
|
| <meta charset="utf-8">
|
| <meta name="viewport" content="width=device-width, initial-scale=1">
|
| <title>
|
| generate data form
|
| </title>
|
| </head>
|
| <body>
|
| <h1> sandbox </h1>
|
|
|
| <div id="sandbox">
|
|
|
| </div>
|
|
|
| <script>
|
|
|
|
|
| let masterObj = JSON.stringify(
|
| <?php
|
|
|
|
|
|
|
|
|
| require 'vendor/autoload.php';
|
| use DOM\HTMLDocument as DOMDocument;
|
|
|
| /* produced doc will have 125 entries (5**3) */
|
|
|
|
|
| function get_uid_from_x_username($username){
|
| /* do stuff */
|
|
|
| return $uid;
|
| };
|
|
|
| /* get followers of user */
|
|
|
| /* get user id of ith follower */
|
|
|
| function fake_get_followers_of_x_user($username){
|
| $fake_data = array(
|
| "data" => [
|
| array(
|
| "id" => "test_id",
|
| "name" => "test_name1",
|
| "username" => "test_username1"
|
| ),
|
| array(
|
| "id" => "test_id2",
|
| "name" => "test_name2",
|
| "username" => "test_username2"
|
| ),
|
| array(
|
| "id" => "test_id3",
|
| "name" => "test_name3",
|
| "username" => "test_username3"
|
| ),
|
| array(
|
| "id" => "test_id4",
|
| "name" => "test_name4",
|
| "username" => "test_username4"
|
| ),
|
| array(
|
| "id" => "test_id5",
|
| "name" => "test_name5",
|
| "username" => "test_username5"
|
| ),
|
| ]
|
| );
|
| return $fake_data;
|
| }
|
|
|
|
|
|
|
| /* $initial_obj = get_followers_of_x_user($username); */
|
|
|
| $users = array();
|
|
|
| function generate_id($depth, $index){
|
|
|
| $index = intval($index);
|
| $letters = range("A", "Z");
|
|
|
| $letter = $letters[$depth];
|
| $number = $index;
|
|
|
| $letter_str = (string)$letter;
|
| $number_str = (string)$index;
|
|
|
| return $letter_str . $number_str;
|
| }
|
|
|
| $master_obj = array(
|
| "prose_id" => "A0",
|
| "username" => "Beastie Boys",
|
| "x_id" => "20172395",
|
| "from" => null,
|
| "addedby" => "admin"
|
| );
|
|
|
|
|
| $cw_id = $master_obj["prose_id"];
|
|
|
| function build_graph_level($depth, $obj){
|
|
|
|
|
| if($depth > 2){
|
| return;
|
| }
|
|
|
|
|
|
|
| /* $cw_obj = get_followers_of_x_user($cw_username); */
|
| $cw_obj = fake_get_followers_of_x_user($cw_username);
|
|
|
|
|
| $data = $cw_obj["data"];
|
|
|
|
|
| for($i = 0; $i < 5; $i++){
|
| $prose_id = generate_id($depth, $i);
|
| $new_obj = array(
|
| "prose_id" => $id,
|
| "username" => $data[$i]["username"],
|
| "x_id" => $data[$i]["id"],
|
| "from" => $cw_id,
|
| "addedby" => "admin",
|
| );
|
|
|
| $master_obj[] = $new_obj;
|
| $cw_id = $id;
|
| }
|
|
|
| $depth += 1;
|
|
|
|
|
|
|
| build_graph_level($depth, $new_obj);
|
|
|
|
|
| }
|
|
|
|
|
| $initial_obj = file_get_contents('followers.json');
|
|
|
| build_graph_level(0, $initial_obj);
|
|
|
|
|
|
|
|
|
| function make_csv(){
|
|
|
| }
|
|
|
| function make_json(){
|
|
|
| }
|
|
|
| function make_xml(){
|
|
|
| }
|
|
|
| echo json_encode($master_obj);
|
|
|
| ?>);
|
|
|
| let sandbox = document.getElementById("sandbox");
|
| sandbox.innerText = masterObj
|
|
|
| console.log(masterObj)
|
|
|
|
|
|
|
| </script>
|
| </body>
|
| </html>
|