Php Kingsoft app api-PHP source code

Source: Internet
Author: User
The php Kingsoft Mac interface obtains data in one sentence every day. The php Kingsoft Mac interface obtains data in one sentence every day.

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();}}}

The above is the content of the php Kingsoft app api. For more information, see The PHP Chinese website (www.php1.cn )!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.