StarClassData.php 4.29 KB
<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016-4-12
 * Time: 13:21
 */

namespace LibModels\Wap\Guang;

use Api\Sign;
use Api\Yohobuy;
/**
 * Class StarClassData
 * 星潮教室相关接口
 * @package LibModels\Wap\Guang
 */
class StarClassData
{

    /**
     * 用户当前亲密度,排名
     * @param $uid
     * @return string
     */
    public static function rankInfoDataUrl($uid = 0)
    {
        $param = Yohobuy::param();
        $param['uid'] = $uid;
        $param['method'] = 'app.starClass.rankInfo';
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
    }

    /**
     * 获取资源位数据(url)
     * @param  string  $contentCode  内容位置码
     * @return array                 首页频道数据
     */
    public static function getResourceDataUrl($contentCode)
    {
        $param = Yohobuy::param();
        $param['content_code'] = $contentCode;
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::httpBuildQuery(Yohobuy::SERVICE_URL . 'operations/api/v5/resource/get', $param);
    }


    /**
     * 获取资源位数据
     * @param  string  $contentCode  内容位置码
     * @return array                 首页频道数据
     */
    public static function getResourceData($contentCode)
    {
        $param = Yohobuy::param();
        $param['content_code'] = $contentCode;
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::get(Yohobuy::SERVICE_URL . 'operations/api/v5/resource/get', $param);
    }


    /**
     * 星潮教室-签到
     * @param $uid
     * @return mixed
     */
    public static function sign($uid = 0)
    {
        $param = Yohobuy::param();
        $param['method'] = 'app.starClass.sign';
        $param['uid'] = $uid;
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::get(Yohobuy::API_URL, $param);
    }

    /**
     * 星潮教室-星搭配文章
     * @param $page
     * @param $uid
     * @param $limit
     * @return mixed
     */
    public static function collocationData($page, $uid, $limit)
    {
        $param = Yohobuy::param();
        $param['page'] = $page;
        $param['limit'] = $limit;
        $param['uid'] = $uid ? $uid : 0;
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::get(Yohobuy::SERVICE_URL . 'guang/api/v5/article/getStarClassroomArticleList', $param);
    }

    /**
     * 点赞
     * @param $articleId
     * @param $udid
     * @return mixed
     */
    public static function setPraise($articleId, $udid)
    {
        $param = Yohobuy::param();
        $param['articleId'] = $articleId;
        $param['udid'] = $udid;
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::get(Yohobuy::SERVICE_URL . 'guang/api/v5/praise/setPraise', $param);
    }

    /**
     * 分享星搭配文章获得亲密度
     * @param $uid
     * @return mixed
     */
    public static function forward($uid = 0)
    {
        $param = Yohobuy::param();
        $param['method'] = 'app.starClass.forward';
        $param['uid'] = $uid;
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::get(Yohobuy::API_URL, $param);
    }

    /**
     * 收藏资讯文章
     * @param $articleId
     * @param $uid
     * @param $type
     * @return mixed
     */
    public static function setFavorite($articleId, $uid, $type)
    {
        //根据type判断调取收藏or取消收藏接口
        if (!empty($type) && $type == 'fav') {
            $url = 'guang/api/v1/favorite/setFavorite';
        }elseif($type == 'del'){
            $url = 'guang/api/v1/favorite/cancelFavorite';
        }

        $param = Yohobuy::param();
        $param['article_id'] = $articleId;
        $param['uid'] = $uid ? $uid : 0;
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::get(Yohobuy::SERVICE_URL . $url, $param);
    }


    /**
     * 排名前100
     * @param $uid
     * @return mixed
     */
    public static function topData($uid = 0)
    {
        $param = Yohobuy::param();
        $param['method'] = 'app.starClass.top100';
        $param['uid'] = $uid;
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::get(Yohobuy::API_URL, $param);
    }
}