2012-03-06 47 views
0

我試圖讓管理員發佈的活動對每個網絡成員都可見,而不僅僅是他們的朋友。 據我所知,表格流正在阻止我的信息公開,它只會發送個人信息。僅在其Feed中可見。 有沒有人有任何想法如何執行此?我使用了我創建的一些設置(例如,來自twitter的screen_name以及在feed中發佈tweet的用戶)。我的代碼如下所示。 代碼如下: - >檢查是否有Twitter用戶閱讀其消息的設置。 - >將它保存在表格中 - >授予(理論上)給每個人閱讀此消息,ether是發佈人的朋友或不是。 - >添加我也創建的活動。如何讓每個人都能在社交引擎上看到活動?

$TwitterUser = Engine_Api::_()->getApi ('settings', 'core')->getSetting ('core.twitter.screen_name'); 

if ($TwitterUser != '') { 
    // Ultimo tweet postado 
    $TwitterUser = Engine_Api::_()->getApi ('settings', 'core')->getSetting ('core.twitter.screen_name'); 
    $table = Engine_Api::_()->getDbtable ('tweets', 'user'); 
    $query = $table->select()->order ('tweets_id desc')->limit(1); 

    $lastTweet = $table->fetchRow ($query); 
    // Set the configuration parameters 
    $config = array ('adapter' => 'Zend_Http_Client_Adapter_Socket', 'ssltransport' => 'tls'); 

    // Instantiate a client object 
    if (is_null ($lastTweet)) { 
     $client = new Zend_Http_Client ("http://api.twitter.com/1/statuses/user_timeline.json?screen_name=$TwitterUser&count=4&include_rts=1", $config); 
    } else { 
     $client = new Zend_Http_Client ("http://api.twitter.com/1/statuses/user_timeline.json?screen_name=$TwitterUser&include_rts=1&since_id=" . $lastTweet->real_id, $config); 
    } 
    // The following request will be sent over a TLS secure connection. 
    $response = $client->request();  
    // Pegando a resposta 
    $body = json_decode ($response->getBody()); 
    if (! empty ($body)) { 
     $db = Engine_Api::_()->getDbtable('tweets', 'user')->getAdapter(); 
     $db->beginTransaction(); 

     try 
     { 
     $table = Engine_Api::_()->getDbtable ('users', 'user'); 
     $twitter_user = $table->fetchRow ($table->select()->where ('user_id = ?', Engine_Api::_()->getApi ('settings', 'core')->getSetting ('core.twitter.user_id'))); 
     $table = Engine_Api::_()->getDbtable ('tweets', 'user'); 
     $activityApi = Engine_Api::_()->getDbtable ('actions', 'activity'); 
     foreach (array_reverse($body) as $tweet) { 
      $data = explode (' ', $tweet->created_at); 
      $meses = array ('Jan' => '01', 'Fev' => '02', 'Mar' => '03', 'Apr' => '04', 'May' => '05', 'Jun' => '06', 'Jul' => '07', 'Aug' => '08', 'Sep' => '09', 'Oct' => '10', 'Nov' => '11', 'Dec' => '12'); 
      $tweet_date = $data ['5'] . "-" . $meses [$data [1]] . '-' . $data [2] . " " . $data [3]; 
      $tweet_date = (date ('Y-m-d H:i:s', strtotime ($tweet_date))); 
      $last_tweet = $table->createRow(); 
      $last_tweet->setFromArray(array(
        'real_id' => $tweet->id_str, 
        'user_id' => $tweet->user->id_str, 
        'screen_name' => $tweet->user->screen_name, 
        'body' => $tweet->text, 
        'retweeted' => $tweet->retweeted, 
        'created_at' => $tweet_date, 
        'profile_image_url' => $tweet->user->profile_image_url, 
        'coordinates' => $tweet->coordinates 
      )); 
      $last_tweet->save(); 
      // Authorizations 
      $auth = Engine_Api::_()->authorization()->context; 
      $auth->setAllowed($last_tweet, 'everyone', 'view', true); 
      $auth->setAllowed($last_tweet, 'everyone', 'comment', true); 
      $auth->setAllowed($last_tweet, 'everyone', 'likes', true); 
      $action = $activityApi->addActivity ($twitter_user,$last_tweet, 'post_twitter', $tweet->text); 
      if($action) { 
       $activityApi->attachActivity($action, $last_tweet); 
      } 
     } 
     // Commit 
     $db->commit(); 
     } catch (Exception $e) { 
       $db->rollBack(); 
       throw $e; 
      } 
     } 
} 

沒有問題發生,但是我正在跟蹤的推文可能會被我用來發布它的用戶發紅。

+0

有人可能會回答這個問題嗎?你根本沒有提供任何細節。什麼網絡?什麼活動?什麼表流?什麼信息?什麼飼料?執行什麼?哪些代碼失敗?你期望它做什麼?你是否收到錯誤信息?請幫助我們來幫助你!向我們展示codez! – vascowhite 2012-03-06 20:02:40

+0

老兄在閱讀標籤之前做出判斷!你知道什麼是社交引擎?如果你編程社交引擎,你可能應該知道我在說什麼 – Palantir 2012-03-06 20:32:12

回答

0

您應該在流表中爲此action_id創建條目。