-
Notifications
You must be signed in to change notification settings - Fork 0
/
profilecreator.php
63 lines (51 loc) · 2.12 KB
/
profilecreator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
require_once('includes.php');
require_once('SMNIncludes.php');
if( !ini_get('safe_mode') ){
set_time_limit(0);
ini_set('memory_limit', '512M');
}
$existing_users = SMNUserQueries::allUsers();
$fh = fopen(dirname(__FILE__)."/api/cached_profiles/"."allusers.json", 'w');
$json_users = json_encode($existing_users);
fwrite($fh, $json_users);
fclose($fh);
echo "created alluserlist".PHP_EOL;
foreach($existing_users as $key => $user) {
try {
$profile = new SMNProfile($user);
$profile_array = array();
$profile_array['uri'] = $profile->showUserUri();
$uri = $profile_array['uri'];
$shortversion = substr($uri, strrpos($uri, "=")+1);
if($profile_array['uri']==false) {
echo 'User not found, please register first!';
}
$profile_array['name'] = $profile->showName();
$profile_array['screen_name'] = $profile->showScreenName();
$profile_array['location'] = $profile->showLocation();
$profile_array['image']=$profile->showImage();
$profile_array['description']=$profile->showDescription();
$profile_array['friends'] = $profile->showFriendUris();
$profile_array['mentions'] = $profile->showMentions();
$profile_array['scientific_events']=$profile->showEvents();
$profile_array['persons']=$profile->showEntities('Person');
$profile_array['places']=$profile->showEntities('Place');
$profile_array['general_events']=$profile->showEntities('Event');
$profile_array['organisations']=$profile->showEntities('Organisation');
$profile_array['tags']=$profile->showInterests();
$profile_json = json_encode($profile_array);
$ourFileName = urlencode($shortversion).".json";
echo "created".$ourFileName.PHP_EOL;
$fh = fopen(dirname(__FILE__)."/api/cached_profiles/".$ourFileName, 'w');
fwrite($fh, $profile_json);
fclose($fh);
} catch (Exception $exception) {
echo $exception->getMessage().PHP_EOL;
}
}
?>