Facebook上同一条帖子中的多个照片和视频

时间:2019-02-20 22:04:22

标签: php facebook-graph-api

我尝试在Facebook上创建包含多张照片和视频的帖子。我是这样做的:

  • 创建照片
  • 创建视频
  • 使用参数attached_media创建帖子

        $fb = new \Facebook\Facebook([
            'app_id' => '...',
            'app_secret' => '...',
            'default_graph_version' => 'v3.2',
        ]);
    
        // photos
        $fbPhotos = [];
    
        foreach ($images as $image) {
            $response = $fb->post(
                "/$pageId/photos",
                ['url' => $image, 'published' => false],
                $accessToken
            );
    
            $graphNode = $response->getGraphNode();
    
            $fbPhotos[] = $graphNode['id'];
        }
    
        // videos
        foreach ($videos as $video) {
            $response = $fb->uploadVideo(
                "/$pageId/videos",
                $video,
                ['title' => 'title', 'description' => 'description', 'published' => false],
                $accessToken
            );
    
            $fbVideos[] = $response['video_id'];
        }
    
        // post
        $response = $fb->post(
            "/$pageId/feed",
            [
                'message' => $message,
                'published' => true,
                'attached_media' => json_encode(array_map(
                    function($v) { return ['media_fbid' => $v]; },
                    array_merge($fbPhotos, $fbVideos)
                )),
            ],
            $accessToken
        );
    

对于上一个请求,我收到错误OAuth "Facebook Platform" "invalid_request" "(#10) Application does not have permission for this action。如果我在$fbVideos帖子中发送的最后一封没有attached_media的请求成功创建了多张照片。

是否可以用多张照片和视频创建同一条帖子?有什么想法吗?

0 个答案:

没有答案