<?php
defined('IN_TS') or die('Access Denied.');
		$url = _post('url');
		//$url ='http://item.taobao.com/item.htm?id=14662154382';
		$collecttype=$TS_SITE['base']['collecttype'];
		if($collecttype==1)
		{
		 /*
		 *使用云服务器采集，向服务器发送数据
		 */
		  $returndata=collected($url);
		  if($returndata['status']=='-1'){
			$json = array(
			'code'=>103,
			'userSns'=>array(
				'qzone'=>'off',
			),
			'product'=>array(
				'code'=>100,
				'url'=>SITE_URL.tsurl('baobei',$returndata['goods_id']),
			),
			);
		}
		else
		{/*
		  *向云服务器发送数据进行采集
		  */
		  $commentarr=array();//存储云服务器采集来的商品评论
		  $commentarr['flag']=0;//判断评论是否提交，0表示没有提交，1表示已经提交过了
		  $lic_username=$TS_SITE['base']['lic_username'];
		  $site_lication=md5($TS_SITE['base']['site_lication']);
		  $return=aac('share')->getyun_goodinfo_by_url($url);
		  if($return)
		  {
		  /*
		   *获取评论中的前八条评论
		   */
		  foreach ($return['data']['comment'] as $key=>$value)
		  {
			  if($key<=7)
			  {
			    $commentarr['content'][$key]=$value;
			  }
		  }
		  fileWrite('comment_data.php','data',$commentarr);
			$tag = explode(' ',$return['data']['defaulttags']);
			$imgs = $return['data']['pic_url'];
			$json = array(
			'code'=>100,
			'userSns'=>array(
				'qzone'=>'off',
			),
			'product'=>array(
				'code'=>100,
				'id'=>'51886191df56923aef39f02a',
				'imgs'=>$imgs,
				'name'=>$return['data']['name'],
				'pid'=>'',
				'info'=>$return['data']['info'],
				//'cate_id'=>$return['data']['tid'],
				//'cate_id'=>$return['cate_id'],
				'defaulttags'=>$return['data']['defaulttags'],
				//'cate_name'=>$return['cate_name'],
				'price'=>$return['data']['price'],
				'tags'=>$return['data']['tags'],
				'url'=>$return['data']['url'],
			),
			);
		  }
		}  
	}
	else
	{/*
		  *使用本地采集
		  */
		 $return=aac('share')->get_goodinfo_by_url($url);

		 if($return['status']=='2'){
			$json = array(
			'code'=>103,
			'userSns'=>array(
				'qzone'=>'off',
			),
			'product'=>array(
				'code'=>100,
				'url'=>SITE_URL.tsurl('baobei',$return['goods_id']),
			),
			);
		}elseif($return['status']=='1'){
			$tag = explode(' ',$return['defaulttags']);
			$imgs = $return['pic_url'];
			
			
			$json = array(
			'code'=>100,
			'userSns'=>array(
				'qzone'=>'off',
			),
			'product'=>array(
				'code'=>100,
				'id'=>'51886191df56923aef39f02a',
				'imgs'=>$imgs,
				'name'=>$return['name'],
				'pid'=>'',
				'info'=>$return['info'],
				'cate_id'=>$return['cate_id'],
				'defaulttags'=>$return['defaulttags'],
				'cate_name'=>$return['cate_name'],
				'price'=>$return['price'],
				'tags'=>$return['tags'],
				'url'=>$return['url'],
			),
			);
		}else{
			
			$json['status'] = 0;
			$json['msg'] = "加载失败，请确认网址无误";	
			
		}
	}

		outputJson($json);


