function getSocialUser() { global $twitterFollowers; global $facebookFriends; global $relationshipStatus; global $politicalViews; global $logFileHandle; $thisUser = getUserBasics(); $yob = substr($thisUser["birthday"], 0, 4); $age = date("Y") - $yob; $userValues["domain"] = getDomain(); fwrite($logFileHandle, "<p>The domain is " . $userValues["domain"]); $userValues["identifier"] = getIdentifier($userValues["domain"]); /******************* Facebook ************************/ if ($userValues["domain"] == "facebook.com") { if ($age > 18 && rand(1, 100) > 20) { $userValues["profile"]["relationshipStatus"] = getRelationshipStatus($age); } // if (!empty($relStatus)) { $userValues["profile"]["relationshipStatus"] = $relStatus; } // get political views if ($thisUser["primaryAddress"]["country"] == "United States") { if (rand(1, 100) > 61) { $polViews = getRandomValue($politicalViews); $userValues["profile"]["politicalViews"] = skewPoliticalViews($polViews, $age, $thisUser["gender"], $thisUser["primaryAddress"]["stateAbbreviation"]); } } $range = getRandomValue($facebookFriends); $numberOfFBfriends = rand($range["min"], $range["max"]); fwrite($logFileHandle, "<p>The number of friends is: " . $numberOfFBfriends); $userValues["friends"] = getFriendsOrFollowersArray($numberOfFBfriends, $userValues["domain"]); //*************** Interests, Movies, Books, Music **************/ // parameters: &attribute_name=profiles%23181683&uuid=ea1bc321-4320-4fbb-8f07-fb939b90cf46&value={"profile":{"interests":[{"interest":"scrapbooking"},{"interest":"cats"},{"interest":"dogs"}],"movies":[{"movie":"Platoon"},{"movie":"Star+Trek+Into+Darkness"}],"books":[{"book":"Call+It+Sleep"},{"book":"The+Death+of+the+Heart"},{"book":"The+French+Lieutenant%27s+Woman"}],"music":[{"music":"Britney+Spears"}]}} $psychInfoTypes = array("interests" => "interest", "movies" => "movie", "books" => "book", "music" => "music"); foreach ($psychInfoTypes as $categoryName => $itemName) { $numberOfItems = getNumberOfItems($itemName); $itemString = $itemName . "s"; if ($itemName == "music") { $itemString = $itemName . " artists"; } fwrite($logFileHandle, "<p>The number of {$itemString} is: " . $numberOfItems); if ($numberOfItems > 0) { $userValues["profile"][$categoryName] = getItems($itemName, $numberOfItems); } } } /********************* Twitter ***********************/ if ($userValues["domain"] == "twitter.com") { $range = getRandomValue($twitterFollowers); $numberOfTWfollowers = rand($range["min"], $range["max"]); fwrite($logFileHandle, "<p>The number of followers is: " . $numberOfTWfollowers); $userValues["followers"] = getFriendsOrFollowersArray($numberOfTWfollowers, $userValues["domain"]); } $thisUser["profiles"] = array(); $thisUser["profiles"][] = $userValues; return $thisUser; }
function createBatch($batchSize, $i = 1) { global $logFileHandle; global $thisArray; fwrite($logFileHandle, "<p>----------------------------------------------</p>"); fwrite($logFileHandle, "<p>Sub-batch number {$i}"); $numberOfSocialUsers = intval($batchSize * SOCIAL_RATIO); $numberOfTradUsers = intval($batchSize * TRAD_RATIO); /******************* Start Social Users ********************************/ /***********************************************************************/ fwrite($logFileHandle, "<p>----------------------------------------------</p>"); fwrite($logFileHandle, "<p>Now creating data for social users...</p>"); for ($i = 1; $i <= $numberOfSocialUsers; $i++) { fwrite($logFileHandle, "<p>--------------------------------------------</p>"); fwrite($logFileHandle, "<p>The user number is " . $i . " of " . $numberOfSocialUsers); $socialUserBatch[] = getSocialUser(); } $jsonResponse = uploadUserBatch("dataOnly", $socialUserBatch); $jsonArray = evaluateJSONresponse($jsonResponse, "createSocialUserBatch"); if ($jsonArray["stat"] == "ok") { fwrite($logFileHandle, "<p>The social batch uploaded successfully."); $content = $jsonResponse; } else { exit; } // I don't want to create trad users if the // social user batch did not upload successfully. /******************* Start Traditional Users ********************************/ /***************************************************************************/ fwrite($logFileHandle, "<p>******************************************</p>"); fwrite($logFileHandle, "<p>Starting to generate data for trad users...</p>"); $userBatch = array(); for ($i = 1; $i <= $numberOfTradUsers; $i++) { // creates an array of randomly generated // demographic values $userBatch[] = getUserBasics("trad"); } $jsonResponse = uploadUserBatch("dataOnly", $userBatch, "trad"); $jsonArray = evaluateJSONresponse($jsonResponse, "createTradUserBatch"); if ($jsonArray["stat"] == "ok") { fwrite($logFileHandle, "<p>The trad batch uploaded successfully."); $content .= $jsonResponse; $thisArray["status"] = "OK"; } else { fwrite($logFileHandle, "<p>The trad batch did not load."); } return $content; }