search
Homephp教程PHP源码php金山词霸api

php金山词霸api

May 25, 2016 pm 04:58 PM
apiphp

php金山词霸接口 每日一句获取数据

error_reporting(E_ALL^E_NOTICE);
ini_set("max_execution_time",300); 
header('Content-Type:text/html; charset=utf-8'); 
try{
$pdo_conn=new PDO('mysql:host=localhost;dbname=iciba_data','root','');
}catch(PDOException $e){
	echo 'conn error'.$e->getMessage();
}
$pdo_conn->exec('set names utf8;');

for($i=0;$i>-990;$i--)
{
	$time=date("Y-m-d",strtotime("$i day"));
	$content=file_get_contents('http://open.iciba.com/dsapi/?date='.$time);
	$arr=json_decode($content,$assoc=true);
	if(!empty($arr))
	{
		echo '';
		print_r($arr);
		echo '';
		$arr[content]=addslashes($arr[content]);
		$arr[note]=addslashes($arr[note]);
		$arr[translation]=addslashes($arr[translation]);
		if(!empty($arr[tags]) and is_array($arr[tags]))
		{	$tags='';
			$num=0;
			foreach($arr[tags] as $tag)
			{
				$qu_tag="select count(id) from i_tags where id=$tag[id]";
				$re_tag=$pdo_conn->query($qu_tag);
				$result = $re_tag->fetchColumn();
				if($result==0)
				{
					$ta_ins="insert into i_tags(id,name)values('$tag[id]','$tag[name]')";
					$pdo_conn->exec($ta_ins);
				}
				if($num==0)
				{
					$tags.=$tag[name];		
				}else
				{
					$tags.='|'.$tag[name];
				}
				$num++;
			}
		}
		$tags=empty($tags)?'':$tags;
		 $query="insert into i_sentence	(sid,tts,content,note,love,translation,picture,picture2,
		 caption,dateline,s_pv,sp_pv,tags,fenxiang_img)values
		('$arr[sid]','$arr[tts]','$arr[content]','$arr[note]','$arr[love]','$arr[translation]',
		'$arr[picture]','$arr[picture2]','$arr[caption]','$arr[dateline]','$arr[s_pv]','$arr[sp_pv]',
		'$tags','$arr[fenxiang_img]')";
		  
		try{
			$pdo_conn->exec($query);
		}catch(PDOException $e){
			echo 'exec error'.$e->getMessage();
		}
	}
	
}

                   

 以上就是php金山词霸api的内容,更多相关内容请关注PHP中文网(www.php.cn)!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment