Facebook Graph API定时发布视频未显示问题求助
问题:Facebook定时发布视频后仅自己可见,未公开显示
我通过以下代码实现Facebook视频定时发布,但视频到了预定时间仍未出现在页面中。通过视频ID获取链接后,只有我自己能看到该视频,状态和设置published=false时一致。(附:通过ID获取的结果截图、代码截图)
public String upVideoJson(String token, String mess, String urlVideo, String times) { String url = "https://graph.facebook.com/v20.0/me/videos"; HttpClient httpClient = HttpClients.createDefault(); String videoId = null; try { HttpPost httpPost = new HttpPost(url); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); String encodedMess = new String(mess.getBytes("UTF-8"), "ISO-8859-1"); builder.addTextBody("access_token", token, ContentType.TEXT_PLAIN); builder.addTextBody("description", encodedMess, ContentType.create("text/plain", "ISO-8859-1")); builder.addTextBody("file_url", urlVideo, ContentType.TEXT_PLAIN); if (StringUtils.hasText(times)) { builder.addTextBody("scheduled_publish_time", times, ContentType.TEXT_PLAIN); builder.addTextBody("published", Boolean.toString(false)); } HttpEntity multipart = builder.build(); httpPost.setEntity(multipart); HttpResponse response = httpClient.execute(httpPost); HttpEntity responseEntity = response.getEntity(); String responseString = EntityUtils.toString(responseEntity); JSONObject jsonResponse = new JSONObject(responseString); if (jsonResponse.has("id")) { videoId = jsonResponse.getString("id"); } else { System.out.println(token); System.out.println(jsonResponse); } } catch (IOException e) { throw new CustomException(); } return videoId; }
排查方向及解决方法
校验
scheduled_publish_time格式
确保times参数是秒级Unix时间戳,且时间需在当前时间之后至少10分钟、不超过6个月。如果传入的是毫秒级时间戳,必须除以1000转换为秒级。确认访问令牌权限
你的access_token必须包含以下权限:pages_manage_postspages_manage_engagementpublish_video
可通过Facebook Graph API调试工具验证权限完整性。
检查视频审核状态
调用GET /{video-id}?fields=status接口查看视频审核状态,若视频未通过审核,即使到了发布时间也不会公开显示。核实页面角色权限
生成令牌的账号需在目标Facebook页面拥有管理员或编辑角色,仅作者角色无法完成定时发布的公开操作。确认API版本参数规则
检查v20.0版本API中scheduled_publish_time参数的使用要求是否有变更,参考官方文档确认参数约束。验证
published参数逻辑
确认times参数非空且格式正确,确保代码中published=false的逻辑被正确触发。
内容的提问来源于stack exchange,提问作者Nguyen Chi Nghia FX15657
相关产品推荐
相关产品推荐

