public function update_news($media_id, $article, $index = 0)
{
$url = self::API_DOMAIN . 'cgi-bin/material/update_news?access_token=' . $this->get_access_token();
$xml = sprintf('{
"media_id":"%s",
"index":"%s",
"articles": {
"title": "%s",
"thumb_media_id": "%s",
"author": "%s",
"digest": "%s",
"show_cover_pic": "%s",
"content": "%s",
"content_source_url": "%s"
}}', $media_id, $index, $article['title'], $article['thumb_media_id'], $article['author'], $article['digest'], $article['show_cover_pic'], $article['content'], $article['content_source_url']);
$res = HttpCurl::post($url, $xml, 'json');
// 异常处理: 获取时网络错误
if ($res === false) {
return Error::code('ERR_POST');
}
// 判断是否调用成功
if ($res->errcode == 0) {
return array(null, $res);
} else {
return array($res, null);
}
}