Пример #1
0
<?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';
require_once 'Zend/Oauth/Consumer.php';
$do_twitter = new OfuzTwitter();
$configuration = $do_twitter->getTwitterConfig();
/**
 * Set up an instance of the Consumer for use
 */
$consumer = new Zend_Oauth_Consumer($configuration);
/**
 * Get a valid Access Token
 */
$token = $consumer->getRequestToken();
$_SESSION['TWITTER_REQUEST_TOKEN'] = serialize($token);
$_SESSION['TWITTER_ENTRY'] = 'user_login.php';
/**
 * Now redirect user to Twitter site so they can log in and
 * approve our access
 */
$consumer->redirect();
exit;
?>
Пример #2
0
<?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';
    ?>

<table class="layout_columns"><tr><td class="layout_lmargin"></td><td>
<div class="layout_content">
    <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">
Пример #3
0
<?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';
require_once 'Zend/Oauth/Consumer.php';
$do_twitter = new OfuzTwitter();
$configuration = $do_twitter->getTwitterConfig();
/**
 * Set up an instance of the Consumer for use
 */
$consumer = new Zend_Oauth_Consumer($configuration);
/**
 * Someone's knocking at the door using the Callback URL - if they have
 * some GET data, it might mean that someone's just approved OAuth access
 * to their account, so we better exchange our current Request Token
 * for a newly authorised Access Token. There is an outstanding Request Token
 * to exchange, right?
 */
if (!empty($_GET) && isset($_SESSION['TWITTER_REQUEST_TOKEN'])) {
    $token = $consumer->getAccessToken($_GET, unserialize($_SESSION['TWITTER_REQUEST_TOKEN']));
    $tw_user_id = $token->getParam('user_id');
    $tw_screen_name = $token->getParam('screen_name');
    $tw_token = serialize($token);
    /**
Пример #4
0
	<td class="layout_rcolumn">
        <div class="banner60 pad020 text32"><?php 
    echo _('Settings');
    ?>
</div>
	
	<?php 
}
?>
        <div class="banner50 pad020 text16 fuscia_text"><?php 
echo _('Twitter Setup');
?>
</div>
        <div class="contentfull">
        <?php 
$do_twitter = new OfuzTwitter();
$do_twitter->sessionPersistent('do_twitter', 'signout.php', 36000);
$TokenExists = $do_twitter->checkTwitterIntegration();
if ($TokenExists) {
    echo _('Your Ofuz account is integrated with your Twitter account: '), $TokenExists;
    echo '<div class="spacerblock_20"></div>', "\n";
    echo '<br />' . _('Click') . ' <a href="tw_import_friends.php">' . _('HERE') . '</a> ' . _('to import your Twitter contacts.');
    echo '<br /><br />' . _('Click') . ' <a href="tw_import_followers.php">' . _('HERE') . '</a> ' . _('to import the people following you on Twitter.');
} else {
    echo _('Your account is not yet integrated with Twitter. ');
    echo _('Please click ');
    echo '<a href="tw_connect.php">', _('here'), '</a>';
    echo _(' to allow Ofuz to access your Twitter data.');
}
?>
        </div>
Пример #5
0
 /**
  *  sendMessage
  *  This abstract the message sending so we use a general function
  *  that will send email or facebook or twitter based on the user
  *  preferences and settings.
  *  its possible to generate an EmailTemplate on the fly with no records in the DB
  *  Here is an exemple:
  *  <code php>
  *  $do_template = new EmailTemplate();
  *  $do_template->senderemail = "*****@*****.**";
  *  $do_template->sendername = "Philippe Lewicki";
  *  $do_template->subject = "This is an example";
  *  $do_template->bodytext = "This is the content of the sample message";
  *  $do_template->bodyhtml = nl2br($do_template->bodytext);
  *  </code>
  * 
  *  An other example more OO / stylish
  *  <code php>
  *  $do_template = new EmailTemplate();
  *  $do_template->setFrom("*****@*****.**", "Philippe Lewicki")
  *              ->setSubject("This is an example")
  *              ->setMessage("This is the content of the sample message");
  *  </code>
  *  setFrom() is optional, if not provided it takes the do_User data
  *  
  *  Then send the message with:  $contact->sendMessage($do_template);
  * 
  *  If you used a saved EmailTemplate like
  *  $do_template = new EmailTemplate("my template in email template table");
  *  and want the sender to be the currently signed in user, make sure the senderemail field
  *  is empty.
  * 
  *  @param $message an EmailTemplate object.
  *  @param $values an array with values to merge, optional.
  *  
  */
 function sendMessage($template, $values = array())
 {
     if (!is_object($template)) {
         return false;
     }
     if (empty($values)) {
         $values = $this->getValues();
     }
     $this->last_message_sent = false;
     $do_contact_email = $this->getChildContactEmail();
     $email_to = $do_contact_email->getDefaultEmail();
     $this->setLog("\n Sending message to:" . $email_to);
     $contact_link = '<a href="/Contact/' . $this->idcontact . '">' . $this->firstname . ' ' . $this->lastname . '</a>';
     if (strlen($email_to) > 4) {
         if ($this->email_optout != 'y') {
             $emailer = new Ofuz_Emailer('UTF-8');
             if (strlen($template->senderemail) == 0) {
                 $template->setFrom($_SESSION['do_User']->email, $_SESSION['do_User']->getFullName());
             }
             $emailer->setEmailTemplate($template);
             $emailer->mergeArrayWithFooter($values);
             $emailer->addTo($email_to);
             $this->last_message_sent = true;
             return $emailer->send();
         } else {
             $_SESSION['in_page_message'] .= _("<br>" . $contact_link . " has opt-out and will not receive this email");
         }
     } elseif (strlen($this->tw_user_id) > 0) {
         // send direct message using twitter api.
         try {
             $do_twitter = new OfuzTwitter();
             $tw_config = $do_twitter->getTwitterConfig();
             $serialized_token = $do_twitter->getAccessToken();
             $token = unserialize($serialized_token);
             $ofuz_twitter = new Ofuz_Service_Twitter($token->getParam('user_id'), $tw_config, $token);
             $followers = $ofuz_twitter->userFollowers(false);
             if (is_object($followers) && count($followers->user) > 0) {
                 foreach ($followers->user as $follower) {
                     if ($follower->id == $this->tw_user_id) {
                         $merge = new MergeString();
                         $message = $merge->withArray($template->bodytext, $values);
                         $ofuz_twitter->directMessageNew($this->tw_user_id, $message);
                         $do_contact_notes = new ContactNotes();
                         $do_contact_notes->iduser = $_SESSION['do_User']->iduser;
                         $do_contact_notes->note = $message;
                         $do_contact_notes->date_added = date('Y-m-d');
                         $do_contact_notes->idcontact = $this->idcontact;
                         $do_contact_notes->add();
                         return true;
                     }
                 }
             }
             $_SESSION['in_page_message'] .= _("<br>Notification can not be sent to " . $contact_link);
         } catch (Exception $e) {
             $_SESSION['in_page_message'] .= _("<br>Notification can not be sent to " . $contact_link);
         }
     } elseif ($this->fb_userid && $_SESSION["do_User"]->global_fb_connected) {
         // send message using facebook api.
         include_once 'facebook_client/facebook.php';
         include_once 'class/OfuzFacebook.class.php';
         $facebook = new Facebook(FACEBOOK_API_KEY, FACEBOOK_APP_SECRET);
         try {
             $msg = _(' has sent the following message using ofuz') . '<br />';
             $msg .= '<b>' . $template->subject . '</b><br/>' . $template->bodyhtml;
             $facebook->api_client->notifications_send($this->fb_userid, $msg, 'user_to_user');
             //$this->last_message_sent = true;
         } catch (Exception $e) {
             $_SESSION['in_page_message'] .= _("<br>Notification can not be sent to " . $contact_link);
         }
     } else {
         $_SESSION['in_page_message'] .= _("<br>" . $contact_link . " doesn't have a valid email address, facebook account, or twitter id.");
     }
     if ($this->last_message_sent) {
         return true;
     } else {
         return false;
     }
 }
Пример #6
0
    <meta http-equiv="content-style-type" content="text/css" />
    <meta http-equiv="refresh" content="300" />
  </head>
  <body>
  Manual Twitter import.  This page refreshes every 5 minutes. <?php 
echo date('Y-m-d h:m:s');
?>
  </body>
</html>
<?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 **/
//$GLOBALS['cfg_full_path'] = '/server/vhtdocs/ofuz.net/';
include_once 'config.php';
$do_twitter = new OfuzTwitter();
$tw_config = $do_twitter->getTwitterConfig();
$do_twitter->cronGetAccessTokens();
$do_twitter->getValues();
if ($do_twitter->getNumRows() > 0) {
    while ($do_twitter->next()) {
        set_time_limit(300);
        $iduser = $do_twitter->iduser;
        $serialized_token = $do_twitter->tw_token;
        if ($serialized_token) {
            $token = unserialize($serialized_token);
            $tw_user_id = $token->getParam('user_id');
            $ofuz_twitter = new Ofuz_Service_Twitter($tw_user_id, $tw_config, $token);
            $imported = array();
            // Import Notes from friends
            $friends = $ofuz_twitter->userFriends(array('id' => $tw_user_id));
Пример #7
0
 /**
  * New User Registration with Twitter
  * @param object $evtcl
  */
 function eventRegNewTwUser(EventControler $evtcl)
 {
     if ($evtcl->tw_user_id && $evtcl->tw_user_id != '') {
         $do_twitter = new OfuzTwitter();
         if ($evtcl->emailid == '') {
             $err_disp = new Display($evtcl->errPage);
             $msg = "Please enter a valid email id.";
             $err_disp->addParam("message", $msg);
             $evtcl->setDisplayNext($err_disp);
         } elseif ($do_twitter->getOfuzUserID($evtcl->tw_user_id)) {
             $err_disp = new Display($evtcl->errPage);
             $msg = "Sorry! But it seems like you already registered, so please verify youself instead.";
             $err_disp->addParam("message", $msg);
             $evtcl->setDisplayNext($err_disp);
         } else {
             $this->firstname = $evtcl->firstname;
             $this->lastname = $evtcl->lastname;
             $this->email = $evtcl->emailid;
             $this->plan = 'free';
             $this->status = 'active';
             $this->add();
             $this->iduser = $this->getPrimaryKeyValue();
             $this->setSessionVariable();
             $do_twitter->setAccessToken($evtcl->tw_user_id, $evtcl->tw_screen_name, $evtcl->tw_token);
             $text = '';
             $text .= 'Hi ' . $this->firstname . '  </br >';
             $text .= 'Welcome to Ofuz. Thanks for logging in with Twitter. You will not need to use a username and password to login to Ofuz; all you need is the "Sign in with Twitter" button. However, you can set one username as well from the Settings menu, and then you can use the general login instead of Twitter.<br /><br />';
             $text .= 'Thank You !<br /> Ofuz Team';
             $do_template = new EmailTemplate();
             $do_template->senderemail = "*****@*****.**";
             $do_template->sendername = "Ofuz";
             $do_template->subject = "Welcome To Ofuz";
             $do_template->bodytext = $text;
             $do_template->bodyhtml = $do_template->bodytext;
             $this->sendMessage($do_template);
             $evtcl->setUrlNext("welcome_to_ofuz.php");
         }
     } else {
         $err_disp = new Display($evtcl->errPage);
         $msg = _('Sorry! But seems like you are not connected to Twitter. Please connect first.');
         $err_disp->addParam("message", $msg);
         $evtcl->setDisplayNext($err_disp);
     }
 }