-
Notifications
You must be signed in to change notification settings - Fork 8
/
tw_import_followers.php
95 lines (88 loc) · 3.79 KB
/
tw_import_followers.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
/** Ofuz Open Source version is released under the GNU Affero General Public License, please read the full license at: http://www.gnu.org/licenses/agpl-3.0.html **/
// Copyright 2008 - 2010 all rights reserved, SQLFusion LLC, info@sqlfusion.com
/** Ofuz Open Source version is released under the GNU Affero General Public License, please read the full license at: http://www.gnu.org/licenses/agpl-3.0.html **/
$pageTitle = 'Ofuz :: Twitter Setup';
$Author = 'SQLFusion LLC';
$Keywords = 'Keywords for search engine';
$Description = 'Description for search engine';
$background_color = 'white';
include_once('config.php');
include_once('includes/ofuz_check_access.script.inc.php');
$do_twitter = new OfuzTwitter();
$serialized_token = $do_twitter->getAccessToken();
if ($serialized_token) {
include_once('includes/header.inc.php');
?>
<?php $do_feedback = new Feedback(); $do_feedback->createFeedbackBox(); ?>
<table class="layout_columns"><tr><td class="layout_lmargin"></td><td>
<div class="layout_content">
<?php $thistab = 'Contacts'; include_once('includes/ofuz_navtabs.php'); ?>
<?php $do_breadcrumb = new Breadcrumb(); $do_breadcrumb->getBreadcrumbs(); ?>
<div class="grayline1"></div>
<div class="spacerblock_20"></div>
<div class="mainheader">
<div class="pad20">
<span class="headline11"><?php echo _('Import Contacts From Twitter');?></span>
</div>
</div>
<div class="contentfull">
<div class="spacerblock_80"></div>
<div class="spacerblock_80">
<div id="waitimage" class="center_text">
<img class="center_elem" src="/images/wait30.gif" width="30" height="30" alt="" />
</div>
</div>
<?php
$token = unserialize($serialized_token);
$tw_user_id = $token->getParam('user_id');
$tw_screen_name = $token->getParam('screen_name');
$tw_config = $do_twitter->getTwitterConfig();
$ofuz_twitter = new Ofuz_Service_Twitter($tw_user_id, $tw_config, $token);
$followers = $ofuz_twitter->userFollowers(false); // false = do not fetch Status
if (count($followers->user) > 0) {
foreach ($followers->user as $user) {
$user_id = $user->id;
$name = $user->name; // will contain the first and last name
$screen_name = $user->screen_name;
$description = $user->description;
$profile_image_url = $user->profile_image_url;
$url = $user->url;
$friend_data = array(
'user_id'=>$user_id,
'name'=>$name,
'screen_name'=>$screen_name,
'description'=>$description,
'profile_image_url'=>$profile_image_url,
'url'=>$url
);
$do_twitter->importTwitterFriend($friend_data, 'Follower');
}
//rebuilding the userXX_contact table
$contact_view = new ContactView();
$contact_view->setUser($_SESSION['do_User']->iduser);
$contact_view->rebuildContactUserTable();
echo _('Your Twitter followers have been successfully imported.');
echo ' <a href="contacts.php">',_('Go to the Contacts Page'),'</a>';
}
?>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
$("#waitimage").hide(0);
});
//]]>
</script>
<div class="spacerblock_80"></div><div class="spacerblock_80"></div>
</div>
</td><td class="layout_rmargin"></td></tr></table>
<div class="layout_footer"></div>
<?php include_once('includes/ofuz_facebook.php'); ?>
<?php include_once('includes/ofuz_analytics.inc.php'); ?>
</body>
</html>
<?php
} else {
header('Location: settings_twitter.php');
}
?>