php - 如何使用 php 将 youtube api 数据转换为 xml 数据提要?
问题描述
我有一个想法来转换这个 JSON 数据:
https://www.googleapis.com/youtube/v3/videos?part=snippet&chart=mostPopular&maxResults=50®ionCode=us&videoCategoryId=10&key=Mykey
到 xml ,用于提要 Rss 阅读器
如何仅使用 PHP 做到这一点?
我的尊敬
解决方案
Youtube API 只返回 JSON。您可以在代码中加载 json 并使用实现自己的 XML
header('Content-type: text/xml');
// other headers are required
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
echo '<xml>';
// Your data
echo '</xml>';
推荐阅读
- c# - StackExchange.Redis 超时
- javascript - 表示不适合 Safari/Explorer 上的屏幕
- mysql - 将两个选择的计数与子查询相除以获得百分比
- ddev - 我可以在 ddev 中降级 xdebug 吗?
- java - 请放心验证 JSON 正文是否包含列表中的所有字符串
- c# - ServiceStack.Client 服务器发送事件未处理
- javascript - 配置 Axios 和 Flask 以使用 CORS 和 cookie
- python - python中的主成分分析降维
- machine-learning - 为不平衡二元分类对数据进行过采样的过程
- powershell - PowerShell中的多个排除规则