http-post - 使用 Instagram Web Api 发布照片或视频时出错
问题描述
当我发布https://www.instagram.com/media/configure/时,我收到一个禁止错误 (403)
我上传照片 ----->
theUrl = "https://www.instagram.com/rupload_igphoto/" + entityName;
xmlhttp.open("POST", theUrl);
xmlhttp.setRequestHeader("x-instagram-rupload-params",
media_type: 1,
upload_id: Date.now(),
upload_media_height: _img.height,
upload_media_width: _img.width
}));
xmlhttp.setRequestHeader("Content-Type", "image/jpeg");
xmlhttp.setRequestHeader("X-Entity-Name", entityName);
xmlhttp.setRequestHeader(
'X-Entity-Length', chunkSize,
);
xmlhttp.setRequestHeader(
'Offset', 0,
);
<----- 结果 200
媒体配置 ----->
theUrl = "https://www.instagram.com/create/configure/";
xmlhttp.open("POST", theUrl);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.send(
'upload_id=' + _upload_id + '&caption=testing&usertags=&custom_accessibility_caption=&retry_timeout='
)
<----- 结果错误 403
解决方案
尝试在 RequestHeader 中设置 X-CSRFToken。
前任:
xmlhttp.setRequestHeader("X-CSRFToken", "your token");
HTTP 的 403 Forbidden 客户端错误响应代码与服务器发送的相同 表示请求已被理解,但身份验证被拒绝。
此状态类似于 401,但在这种情况下重新认证不会改变结果。访问已被永久禁止,例如您没有访问资源的权限。它与应用程序的逻辑相关。
推荐阅读
- unity3d - 为什么我在 HoloLens 中的 3d 对象一直跟着我并且不稳定?
- ruby-on-rails - 运行“中间人构建”时发生错误
- google-apps-script - 从 google-apps-script 设置 Auth0 应用程序允许的回调 URL
- c# - 列出 .Net 5 中的 ODBC 驱动程序
- pandas - 假设 - 如何生成具有可变列数的熊猫数据框
- javascript - 如何在 Typescript + React Static 组件中添加 TailwindCSS
- c# - SQL : SELECT * FROM 方法
- php - 您如何按 MYSQL 数据库中的两列排序?
- r - 使用 ggplot2 线绘制平均值?
- c++ - 无法从 initializer_list 转换为我的类型,该类型具有模板化的可变参数构造函数