コード例 #1
0
 public function getListAction()
 {
     $request = $_GET;
     $token = isset($request['TOKEN']) ? trim($request['TOKEN']) : null;
     $lastDate = isset($request['lastDate']) ? $request['lastDate'] : null;
     if (!$token) {
         return ['STATUS_CODE' => STATUS_CODE_BAD_REQUEST, 'DATA' => buckys_api_get_error_result('Api token should not be blank')];
     }
     if (!($userID = BuckysUsersToken::checkTokenValidity($token, "api"))) {
         return ['STATUS_CODE' => STATUS_CODE_UNAUTHORIZED, 'DATA' => buckys_api_get_error_result('Api token is not valid.')];
     }
     $stream = BuckysPost::getUserPostsStream($userID, $lastDate);
     //Format Result Data
     $result = [];
     foreach ($stream as $post) {
         if ($post['pageID'] != BuckysPost::INDEPENDENT_POST_PAGE_ID) {
             $pageIns = new BuckysPage();
             $pageData = $pageIns->getPageByID($post['pageID']);
         }
         $pagePostFlag = false;
         if (isset($pageData)) {
             $pagePostFlag = true;
         }
         $item = [];
         $item['articleId'] = $post['postID'];
         $item['posterId'] = $post['poster'];
         $item['articleImage'] = "";
         $item['articleVideo'] = "";
         $item['articleVideoId'] = "";
         if ($pagePostFlag) {
             $item['posterName'] = $pageData['title'];
             $item['posterThumbnail'] = buckys_not_null($pageData['logo']) ? THENEWBOSTON_SITE_URL . DIR_WS_PHOTO . "users/" . $pageData['userID'] . "/resized/" . $pageData['logo'] : THENEWBOSTON_SITE_URL . DIR_WS_IMAGE . "newPagePlaceholder.jpg";
         } else {
             $item['posterName'] = $post['posterFullName'];
             $item['posterThumbnail'] = THENEWBOSTON_SITE_URL . BuckysUser::getProfileIcon($post['poster']);
         }
         $item['postedDate'] = buckys_api_format_date($userID, $post['post_date']);
         $item['purePostedDate'] = $post['post_date'];
         $item['articleContent'] = $post['content'];
         if ($post['type'] == 'video') {
             $item['articleVideo'] = $post['youtube_url'];
             $item['articleVideoId'] = buckys_get_youtube_video_id($post['youtube_url']);
         } else {
             if ($post['type'] == 'image') {
                 $item['articleImage'] = THENEWBOSTON_SITE_URL . DIR_WS_PHOTO . 'users/' . $post['poster'] . '/resized/' . $post['image'];
             }
         }
         $item['articleLikes'] = $post['likes'];
         $item['articleComments'] = $post['comments'];
         $item['isLiked'] = !$post['likeID'] ? "no" : "yes";
         $result[] = $item;
     }
     return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => ["STATUS" => "SUCCESS", "RESULT" => $result]];
 }
コード例 #2
0
ファイル: view.php プロジェクト: kishoreks/BuckysRoom
function render_top_videos($videos)
{
    foreach ($videos as $i => $row) {
        ?>
    <div class="index_singleListing <?php 
        echo ($i + 1) % 4 == 0 ? 'index_singleListingLast' : '';
        ?>
 ">                
        <div class="index_singleListingContent">
            <a class="video" href="/posts.php?user=<?php 
        echo $row['userID'];
        ?>
&post=<?php 
        echo $row['postID'];
        ?>
"><img src="http://img.youtube.com/vi/<?php 
        echo buckys_get_youtube_video_id($row['youtube_url']);
        ?>
/mqdefault.jpg" /></a>
            <div class="video-info">
                <span class="index_timeOfPost">posted <?php 
        echo buckys_format_date($row['post_date']);
        ?>
 <br /> by </span> 
                <a href="/profile.php?user=<?php 
        echo $row['userID'];
        ?>
"><b><?php 
        echo $row['userName'];
        ?>
</b></a> <br/>
                <a href="/posts.php?user=<?php 
        echo $row['userID'];
        ?>
&post=<?php 
        echo $row['postID'];
        ?>
" class="index_LikesAndComments"><?php 
        echo $row['likes'];
        ?>
 Like<?php 
        echo $row['likes'] > 1 ? "s" : "";
        ?>
</a> &middot; <a href="/posts.php?user=<?php 
        echo $row['userID'];
        ?>
&post=<?php 
        echo $row['postID'];
        ?>
" class="index_LikesAndComments"><?php 
        echo $row['comments'];
        ?>
 Comment<?php 
        echo $row['comments'] > 1 ? 's' : '';
        ?>
</a>
            </div>
        </div>
    </div>
    <?php 
    }
    ?>
    <?php 
    if (count($videos) < 1) {
        ?>
    <div class="index_singleListing index_singleListingEmpty"><?php 
        echo MSG_NO_DATA_FOUND;
        ?>
</div>            
    <?php 
    }
}
コード例 #3
0
function render_top_videos($videos)
{
    foreach ($videos as $i => $row) {
        if (!$row['pageID']) {
            $url = "/posts.php?user="******"&post=" . $row['postID'];
        } else {
            $url = "/page.php?pid=" . $row['pageID'] . "&post=" . $row['postID'];
        }
        ?>
        <div class="index_singleListing <?php 
        echo ($i + 1) % 4 == 0 ? 'index_singleListingLast' : '';
        ?>
 ">
            <div class="index_singleListingContent">
                <a class="video" href="<?php 
        echo $url;
        ?>
">
                    <!--<img src="//img.youtube.com/vi/<?php 
        //echo buckys_get_youtube_video_id($row['youtube_url'])
        ?>
/mqdefault.jpg" /> -->
                    <div class="videoThumb"
                        style="    background-image: url('//img.youtube.com/vi/<?php 
        echo buckys_get_youtube_video_id($row['youtube_url']);
        ?>
/mqdefault.jpg');">
                        <div style="width: 235px;">
                            <img src="https://www.thenewboston.com/images/youtube-play-button.png">
                        </div>
                    </div>
                </a>

                <div class="video-info">
                    <span class="index_timeOfPost">posted <?php 
        echo buckys_format_date($row['post_date']);
        ?>
                        <br/> by </span>
                    <?php 
        if (!$row['pageID']) {
            $authorUrl = "/profile.php?user="******"/page.php?pid=" . $row['pageID'];
        }
        ?>
                    <a href="<?php 
        echo $authorUrl;
        ?>
"
                        class="smallBlue"><?php 
        echo !$row['pageID'] ? $row['userName'] : $row['pageTitle'];
        ?>
</a> <br/>
                    <a href="<?php 
        echo $url;
        ?>
"
                        class="index_LikesAndComments"><?php 
        echo $row['likes'];
        ?>
 Like<?php 
        echo $row['likes'] > 1 ? "s" : "";
        ?>
</a> &middot;
                    <a href="<?php 
        echo $url;
        ?>
"
                        class="index_LikesAndComments"><?php 
        echo $row['comments'];
        ?>
 Comment<?php 
        echo $row['comments'] > 1 ? 's' : '';
        ?>
</a>
                </div>
            </div>
        </div>
    <?php 
    }
    ?>
    <?php 
    if (count($videos) < 1) {
        ?>
        <div class="index_singleListing index_singleListingEmpty"><?php 
        echo MSG_NO_DATA_FOUND;
        ?>
</div>
    <?php 
    }
}
コード例 #4
0
ファイル: general.php プロジェクト: kishoreks/BuckysRoom
/**
* Validate the Youtube Video Id
* 
* @param mixed $youtubeID
*/
function buckys_validate_youtube_url($youtubeURL)
{
    $youtubeID = trim(buckys_get_youtube_video_id($youtubeURL));
    if (!$youtubeID) {
        return false;
    }
    $url = 'http://gdata.youtube.com/feeds/api/videos/' . $youtubeID;
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($ch);
    if (strtolower(trim($result)) == 'invalid id') {
        return false;
    } else {
        return true;
    }
}