<?php

namespace App\Http\Controllers;

use App\Services\WeiboService;
use App\Weibo;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;

class WeiboController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
    }

    public function list()
    {
        // Fan_Cam_4K  1076035733650527 page 902
        // 儒雅随和  1076035123577126 page 139
        $url = array();

        for( $i = 139 ; $i >= 1 ; $i-- )
            $url[] = 'https://m.weibo.cn/api/container/getIndex?containerid=1076035123577126&openApp=0&page='.$i;
        return response()->json($url);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
//        die();
//        Log::info($request->input());
        $weibo = new WeiboService();
        $result = $weibo->scrapeWeiboPicAndVideo($request->input("content"));
        return response()->json($result);
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Weibo  $weibo
     * @return \Illuminate\Http\Response
     */
    public function show(Weibo $weibo)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Weibo  $weibo
     * @return \Illuminate\Http\Response
     */
    public function edit(Weibo $weibo)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Weibo  $weibo
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, Weibo $weibo)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Weibo  $weibo
     * @return \Illuminate\Http\Response
     */
    public function destroy(Weibo $weibo)
    {
        //
    }
}
