function getPosts($userid, $minPostId = 0)
 {
     //echo $minPostId;
     $limit = 3;
     $rm = new Response_Methods();
     if ($minPostId != 0) {
         $loadMore = 1;
         $sqlFetchPosts = "SELECT U.user_name_f, U.profile_pic_f, N.post_id, N.post_description_f, N.post_date_f,N.user_id_fk,N.post_image_f,N.image_width_f,N.image_height_f, N.like_count_f,N.thumb1,N.thumb2,N.thumb3,N.thumb4,N.thumb5,N.ipad_portrait_width,N.ipad_portrait_height,N.ipad_landscape_height,N.ipad_landscape_width\nFROM user_details_t U, news_feeds_t N, friends_t F\nWHERE \nN.user_id_fk = U.user_id\nAND \n\nCASE\nWHEN F.friend_one = {$userid}\nTHEN F.friend_two = N.user_id_fk\nWHEN F.friend_two= {$userid}\nTHEN F.friend_one= N.user_id_fk\nEND\n\nAND \nF.status > '0' AND N.post_id < {$minPostId}\nORDER BY N.post_id DESC LIMIT {$limit};";
     } else {
         $loadMore = 0;
         $sqlFetchPosts = "SELECT U.user_name_f, U.profile_pic_f, N.post_id, N.post_description_f, N.post_date_f,N.user_id_fk,N.post_image_f,N.image_width_f,N.image_height_f, N.like_count_f,N.thumb1,N.thumb2,N.thumb3,N.thumb4,N.thumb5,N.ipad_portrait_width,N.ipad_portrait_height,N.ipad_landscape_height,N.ipad_landscape_width\nFROM user_details_t U, news_feeds_t N, friends_t F\nWHERE \nN.user_id_fk = U.user_id\nAND \n\nCASE\nWHEN F.friend_one = {$userid}\nTHEN F.friend_two = N.user_id_fk\nWHEN F.friend_two= {$userid}\nTHEN F.friend_one= N.user_id_fk\nEND\n\nAND \nF.status > '0'\nORDER BY N.post_id DESC LIMIT {$limit};";
     }
     $remainingPosts = $rm->remainingPosts($userid, $minPostId, $limit);
     $dataResultSet = mysql_query($sqlFetchPosts, $GLOBALS['link']);
     $getGrpDetails = array();
     $getArrayList = array();
     if (mysql_num_rows($dataResultSet) > 0) {
         while ($row = mysql_fetch_array($dataResultSet)) {
             $post_id = $row['post_id'];
             $post_description = $row['post_description_f'];
             $post_image = $row['post_image_f'];
             $like_count = $row['like_count_f'];
             $post_date = $row['post_date_f'];
             $post_user_id = $row['user_id_fk'];
             $user_name = $row['user_name_f'];
             $profilePic = $row['profile_pic_f'];
             $imageWidth = $row['image_width_f'];
             $imageHeight = $row['image_height_f'];
             $thumb1 = $row['thumb1'];
             $thumb2 = $row['thumb2'];
             $thumb3 = $row['thumb3'];
             $thumb4 = $row['thumb4'];
             $thumb5 = $row['thumb5'];
             $thumb4_width = $row['ipad_portrait_width'];
             $thumb4_height = $row['ipad_portrait_height'];
             $thumb5_width = $row['ipad_landscape_width'];
             $thumb5_height = $row['ipad_landscape_height'];
             $checkLike = $rm->checkAlreadyLiked($userid, $post_id);
             if ($checkLike > 0) {
                 $like_status = "1";
             } else {
                 $like_status = "0";
             }
             $getGrpDetails['post_id'] = $post_id;
             $getGrpDetails['post_description'] = $rm->removeslashes($post_description);
             $getGrpDetails['post_image_url'] = $post_image;
             $getGrpDetails['like_count'] = $like_count;
             $getGrpDetails['like_status'] = $like_status;
             $getGrpDetails['post_date'] = $post_date;
             $getGrpDetails['user_name'] = $user_name;
             //username posted
             $getGrpDetails['post_user_id'] = $post_user_id;
             //userid posted newsfeed
             $getGrpDetails['profilePic'] = $profilePic;
             $getGrpDetails['post_image_width'] = $imageWidth;
             $getGrpDetails['post_image_height'] = $imageHeight;
             $getGrpDetailsImage['post_image_url_iphone4'] = $thumb1;
             $getGrpDetailsImage['post_image_url_iphone5'] = $thumb1;
             $getGrpDetailsImage['post_image_url_iphone6'] = $thumb2;
             $getGrpDetailsImage['post_image_url_iphone6+'] = $thumb3;
             $getGrpDetailsImage['post_image_url_iPad_portrait'] = $thumb4;
             $getGrpDetailsImage['post_image_url_iPad_landscape'] = $thumb5;
             $getGrpDetailsImageDimension['ipad_portrait_width'] = $thumb4_width;
             $getGrpDetailsImageDimension['ipad_portrait_height'] = $thumb4_height;
             $getGrpDetailsImageDimension['ipad_landscape_width'] = $thumb5_width;
             $getGrpDetailsImageDimension['ipad_landscape_height'] = $thumb5_height;
             $getGrpDetails['post_photos_thumbs'] = $getGrpDetailsImage;
             $getGrpDetails['post_photo_sizes'] = $getGrpDetailsImageDimension;
             //$getGrpDetails['profileId']=$profile_id;
             /*
             						$followArray=$rm->followerFollowingCount($userid);
             						//print_r($followArray);
             						$getGrpDetails['followersCount']=$followArray['followers'];	
             						$getGrpDetails['followingCount']=$followArray['following'];
             */
             array_push($getArrayList, $getGrpDetails);
         }
         //print_r($getArrayList);
         $followArray = $rm->followerFollowingCount($userid);
         //print_r($followArray);
         $followersCount = $followArray['followers'];
         $followingCount = $followArray['following'];
         $newData = json_encode(array($getArrayList));
         $newData = str_replace('\\/', '/', $newData);
         $newData = substr($newData, 1, strlen($newData) - 2);
         $newData = "{\"data\":{\"Error_Code\":\"1\",\"Error_Msg\":\"News Feed List\",\"followersCount\":\"{$followersCount}\",\"followingCount\":\"{$followingCount}\",\"RemainingFeeds\":\"{$remainingPosts}\",\"result\":" . $newData . "}}";
         return $newData;
     } else {
         if ($loadMore == 0) {
             $errorCode = "0";
         } else {
             $errorCode = "22";
         }
         $errorMsg = "No Newsfeeds Available";
         $newData = "{\"data\":{\"Error_Code\":\"" . $errorCode . "\",\"Error_Msg\":\"" . $errorMsg . "\"}}";
         //Json Format Response
         return $newData;
         //Login Unsuccessful
     }
 }