<?php

namespace App\Http\Controllers\Wechat\Api;

use App\Http\Controllers\Controller;
use App\Http\Requests;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use DB;

/**
 * 微信验证
 * @author zhoulingjie
 *
 */
class MPverifysController extends Controller
{
	/**
	 * 从oss上读取文件的内容输出
	 * @param Request $request
	 */
   function mp_verify(Request $request){
   	    $file_name = '';
		preg_match('/wechat\/(.*)?.txt/i',$_SERVER['REQUEST_URI'],$data);
		isset($data[1]) && !empty($data[1]) && $file_name=$data[1];
		
		$file_url = 'http://yueduyun-wechat.oss-cn-hangzhou-internal.aliyuncs.com/mp_verify/'.$file_name.'.txt';
		
    	$contents = @file_get_contents($file_url);
    	v('$file_name:'.$file_name.' $file_url:'.$file_url.' $contents:'.json_encode($contents));
    	if(empty($contents)){
    		echo 'invalid file_url';
    	}else{
    		echo $contents;
    	}
    	exit();
   	   
   }
}