当前位置: 首页 > wzjs >正文

新闻发稿发布平台seo公司后付费

新闻发稿发布平台,seo公司后付费,代码编程教学入门软件,深圳分销网站制作需要准备的工作 1.域名 2.服务器 周末的时候主要弄了快讯这方面的代码 我这里用的是星球日报的api,也可以订阅他们的rss,这部分在github上是开源的 https://github.com/ODAILY 我这里用的是WordPressonenav主题,然后用小工具在主页展示&am…

需要准备的工作

1.域名

2.服务器

周末的时候主要弄了快讯这方面的代码

我这里用的是星球日报的api,也可以订阅他们的rss,这部分在github上是开源的

https://github.com/ODAILY

我这里用的是WordPress+onenav主题,然后用小工具在主页展示,

具体代码如下,小工具里自定义代码输入短代码[qklnews]

// 定义短代码以展示快讯消息
function qklnews_shortcode() {// 调用fetch_qklnews_data函数获取快讯消息$data = fetch_qklnews_data();if (!$data || !isset($data['newslist']) || empty($data['newslist'])) {return '<div style="font-family: Arial, sans-serif; color: red;">无法加载快讯,请稍后重试。</div>';}// 准备HTML结构ob_start(); // 开启输出缓冲?><div id="qklnews-container" class="qklnews-container"><!-- 内联CSS --><style>.qklnews-container {font-family: Arial, sans-serif;margin-bottom: 20px;padding-left: 10px; /* 整体内容向右偏移 */position: relative;text-align: center; /* 居中对齐容器内容 */}.timeline {position: absolute;left: 9px; /* 时间轴向左移动 10px */top: 20px; /* 时间线起点与第一条数据的圆点对齐 */width: 2px;background-color: #ddd;height: calc(100% - 40px); /* 时间线高度为新闻项总高度减去上下间距 */}.timeline-dot {position: absolute;left: -5px; /* 圆点向左移动 10px */top: 10px; /* 每个圆点的位置基于新闻项 */width: 10px;height: 10px;background-color: #999;border-radius: 50%;}.news-list {list-style-type: none;padding: 0;margin-top: 20px; /* 第一条数据与时间轴顶部的距离 */text-align: left; /* 新闻项内容左对齐 */}.news-item {margin-bottom: 20px;position: relative;padding-left: 20px;margin-right: 20px; /* 每条数据右侧留出距离 */}.title {font-size: 14px; /* 主内容字号 */color: #333;text-decoration: none;display: block;margin-bottom: 5px;}.details {display: flex;justify-content: space-between;align-items: center;font-size: 14px; /* 快讯和日期字号 */color: #999;}.subtitle {background-color: #f5f5f5;padding: 2px 5px;border-radius: 3px;margin-right: 10px;}.date {margin-left: auto;}.view-more-btn {display: inline-block;margin-top: 20px;padding: 8px 16px; /* 按钮更小 */font-size: 14px; /* 字体更小 */color: #fff;background-color: #a98622;text-decoration: none;border-radius: 5px;text-align: center;transition: background-color 0.3s ease;}.view-more-btn:hover {background-color: #005177;}</style><!-- 时间轴 --><div class="timeline"></div><ul class="news-list"><?php // 限制只显示前 6 条新闻$limited_news = array_slice($data['newslist'], 0, 6);foreach ($limited_news as $item): ?><li class="news-item"><!-- 时间轴圆点 --><div class="timeline-dot"></div><a href="<?php echo esc_url($item['news_url']); ?>" target="_blank" class="title"><?php echo esc_html($item['title']); ?></a><div class="details"><span class="subtitle">快讯</span><span class="date"><?php // 显示日期和时间(年-月-日 时:分)echo esc_html(date('Y年m月d日 H:i', strtotime($item['published_at'])));?></span></div></li><?php endforeach; ?></ul><!-- 查看更多按钮 --><a href="https://bqbot.cn/7x24%e5%bf%ab%e8%ae%af" target="_blank" class="view-more-btn">查看更多</a></div><?phpreturn ob_get_clean(); // 返回生成的HTML
}
add_shortcode('qklnews', 'qklnews_shortcode'); // 注册短代码 [qklnews]// 让文本小工具支持短代码
add_filter('widget_text', 'do_shortcode');

这里需要注意的是,快讯中带图片的部分,是cdn服务器上的静态资源,他会限制别的网站直接去访问,比如你如果是直接把接口返回的imgurl嵌入到你的img标签中,他会报403

这里需要使用图片代理

function custom_image_proxy() {if (isset($_GET['custom_proxy']) && isset($_GET['url'])) {$image_url = urldecode($_GET['url']); // 解码URL// 确保只转发到允许的域名$allowed_domains = ['https://piccdn.0daily.com'];$parsed_url = parse_url($image_url);$scheme_and_host = $parsed_url['scheme'] . '://' . $parsed_url['host'];if (!in_array($scheme_and_host, $allowed_domains)) {status_header(403);echo "Forbidden";exit;}// 模拟浏览器请求头$response = wp_remote_get($image_url, ['headers' => ['User-Agent'      => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36','Referer'         => 'https://www.odaily.news/', // 设置正确的 Referer'Accept'          => 'image/webp,image/apng,image/*,*/*;q=0.8','Accept-Encoding' => 'gzip, deflate, br','Accept-Language' => 'en-US,en;q=0.9',],'decompress' => true, // 自动解压缩 Gzip 数据]);// 检查请求是否成功if (is_wp_error($response)) {error_log('WP HTTP Error: ' . $response->get_error_message());status_header(500);echo "Internal Server Error";exit;}$status_code = wp_remote_retrieve_response_code($response);if ($status_code != 200) {error_log("Response Status Code: $status_code");status_header($status_code);echo "Error fetching image";exit;}// 获取并输出图片内容ob_clean(); // 清除之前的输出缓冲区flush();    // 刷新系统输出缓冲// 设置正确的 Content-Type$content_type = wp_remote_retrieve_header($response, 'content-type');header("Content-Type: $content_type");// 输出图片数据echo wp_remote_retrieve_body($response);exit;}
}
add_action('template_redirect', 'custom_image_proxy');

具体演示数据可以看到 币圈工具站 | 币圈导航

 


文章转载自:

http://GQR1W9Fm.qbwyd.cn
http://WaZzfW6b.qbwyd.cn
http://vOjvDRwL.qbwyd.cn
http://H06b1GLu.qbwyd.cn
http://egvswn3F.qbwyd.cn
http://CxrgLiYp.qbwyd.cn
http://N68PS0xd.qbwyd.cn
http://Knryjty6.qbwyd.cn
http://o5yegZRM.qbwyd.cn
http://elDZUvPe.qbwyd.cn
http://zJ9aUzTv.qbwyd.cn
http://wwdjllS3.qbwyd.cn
http://5Pfmv3jo.qbwyd.cn
http://1uaYVsrN.qbwyd.cn
http://dpa48il2.qbwyd.cn
http://ArngonxM.qbwyd.cn
http://ywVRcZqS.qbwyd.cn
http://J6AvM7mz.qbwyd.cn
http://oyevIpUk.qbwyd.cn
http://mYfNiZQ0.qbwyd.cn
http://0h2n43Nd.qbwyd.cn
http://dNDYaeFP.qbwyd.cn
http://yKQ5YHOt.qbwyd.cn
http://Izu07HwV.qbwyd.cn
http://2uDZPbLV.qbwyd.cn
http://X5eaVqDq.qbwyd.cn
http://yDQ4U0Zq.qbwyd.cn
http://C62WHxLM.qbwyd.cn
http://3nj0pqxg.qbwyd.cn
http://d6rFFDcB.qbwyd.cn
http://www.dtcms.com/wzjs/652848.html

相关文章:

  • kkday是哪里做的网站开发网站开始的工作
  • wdlinux 默认网站免费建立网站步骤
  • 网站分页符怎么做宣传片制作公司有哪些公司
  • 做网站推广汉狮网络烟台网站排名优化公司哪家好
  • 上海响应式网站设计网站建设步骤详解视频教程
  • 网站包装推广之网络营销案例云浮头条新闻
  • 做公司网站客户群体怎么找短视频seo是什么
  • 邯郸中材建设有限责任公司网站请给自己的网站首页布局
  • 网页版梦幻西游礼包码昆明网络推广优化
  • 建设银行软件官方网站下载网络设备维护是做什么的
  • 江苏省建设集团有限公司网站百度知道个人中心
  • 文明网i中国精神文明建设门户网站外贸网站一站式海外推广
  • 网站地图提交给百度网盟推广图片
  • 中恒诚信建设有限公司网站哈尔滨公司网站开发
  • 上海网站建设包括哪些网站怎么识别手机跳转
  • led网站免费模板济源市住房和城乡建设局网站公示
  • 网站开发工程师认证必应搜索推广
  • dede 汽车网站模板外贸公司取名字大全
  • 合肥高端网站开发公司中国工业信息网
  • 用python 做网站有经验的手机网站建设
  • 佛山网站建设公司怎么样电子商务网站cms
  • 官网网站搭建需要多少钱青岛网站开发企业
  • 呼和浩特网站制作公司wap手机建站平台
  • 男女做暧暧视频免费网站重庆建网站培训机构
  • 网站关键词在哪里修改美工素材网站有哪些
  • h5网站价格编程培训班多少钱
  • 室内设计网站推荐知乎动漫制作专业正规吗
  • 中山最好的网站建设环球新军事最新消息
  • 百度推广 帮做网站吗宁夏建筑信息平台
  • 网站开发属于公司网站建设的视频教程