Example #1
0
 /**
  * Get the responses of a plurk. This method will load "temporary" friends 
  * who have responded to the plurk.
  *
  * @param int $int_plurk_id The plurk ID 
  *
  * @return array The array of responses.
  */
 function plurk_response_get($int_plurk_id)
 {
     $this->plurk_post($this->plurk_paths['plurk_response_get'], array('plurk_id' => $int_plurk_id));
     $data = $this->plurk_response();
     $string_response = $data['body'];
     $data = explode('"responses": ', $string_response);
     preg_match('/\\{"friends": \\{"\\d+": (.*)\\}, "responses/', $data[0], $local_friend);
     if (isset($local_friend[1])) {
         $temp_friends = array();
         $each_friend_almost_json = preg_split('/\\}, "\\d+": \\{/', $local_friend[1]);
         foreach ($each_friend_almost_json as $friend_data) {
             if (substr($friend_data, 0, 1) != '{') {
                 $friend_data = '{' . $friend_data;
             }
             if (substr($friend_data, strlen($friend_data) - 1, strlen($friend_data)) != '}') {
                 $friend_data = $friend_data . '}';
             }
             $temp_friends = array_merge($temp_friends, al_plurk_api::dejsonize($friend_data));
         }
         $this->friends = array_merge($this->friends, $temp_friends);
     }
     $responses = array();
     if (isset($data[1])) {
         $response_data = substr($data[1], 0, strlen($data[1]) - 1);
         $responses = al_plurk_api::dejsonize($response_data);
         foreach ($responses as &$each_response) {
             $each_response['nick_name'] = $this->uid_to_nickname($each_response['user_id']);
         }
     }
     return $responses;
 }