I have used Faker to generate persons and I want to do the same thing using Wikidata. By getting names, date of birth, gender, first paragraph and other specified similar data. In addition being able to avoid duplicates by checking existing persons (e.g Q4926) I have fetched before. Wikidata Query = https://w.wiki/5LUr
Is it possible to use freearhey/wikidata or addwiki/wikibase-api or should query.wikidata.org/sparql be used diretly
Code snippet currently used
if ($s == 'generate_fake_users') {
require "assets/libraries/fake-users/vendor/autoload.php";
$faker = Faker\Factory::create();
if (empty($_POST['password'])) {
$_POST['password'] = '123456789';
}
$count_users = $_POST['count_users'];
$password = $_POST['password'];
$avatar = $_POST['avatar'];
ob_end_clean();
header("Content-Encoding: none");
header("Connection: close");
ignore_user_abort();
ob_start();
header('Content-Type: application/json');
echo json_encode(array(
'status' => 200
));
$size = ob_get_length();
header("Content-Length: $size");
ob_end_flush();
flush();
session_write_close();
if (is_callable('fastcgi_finish_request')) {
fastcgi_finish_request();
}
for ($i=0; $i < $count_users; $i++) {
$genders = array_keys($wo['genders']);
$random_keys = array_rand($genders, 1);
$gender = array_rand(array("male", "female"), 1);
$gender = $genders[$random_keys];
$re_data = array(
'email' => Site_Secure(str_replace(".", "_", $faker->userName) . '_' . rand(111, 999) . "@domain.com", 0),
'username' => Site_Secure($faker->userName . '_' . rand(111, 999), 0),
'password' => Site_Secure($password, 0),
'email_code' => Site_Secure(md5($faker->userName . '_' . rand(111, 999)), 0),
'src' => 'Fake',
'gender' => Site_Secure($gender),
'lastseen' => time(),
'active' => 1,
'first_name' => $faker->firstName($gender),
'last_name' => $faker->lastName
);
if ($avatar == 1) {
$urls = array("http://lorempixel.com/".$wo['profile_picture_width_crop']."/".$wo['profile_picture_height_crop']."/people","https://placeimg.com/".$wo['profile_picture_width_crop']."/".$wo['profile_picture_height_crop']."/people");
$rand = rand(0,1);
$url = $urls[$rand];
$a = Site_ImportImageFromFile($url,'_url_image','avatar');
if (!empty($a)) {
$re_data['avatar'] = $a;
}
}
$add_user = Site_RegisterUser($re_data);
}
header("Content-type: application/json");
echo json_encode($data);
exit();
}