function PostVideo() { if (!isset($_POST['source']) || $_POST['source'] == "") { return "Missing required param"; exit; } $config = (include "/config.php"); $fb = new Facebook\Facebook(['app_id' => $config['app_id'], 'app_secret' => $config['app_secret'], 'default_graph_version' => 'v2.4']); $data = ['source' => $fb->videoToUpload($_POST['source'])]; if (isset($_POST['description']) && $_POST['description'] != "") { $data['description'] = FilterText($_POST['description']); } if (isset($_POST['title']) && $_POST['title'] != "") { $data['title'] = FilterText($_POST['title']); } try { $response = $fb->post('/me/videos', $data, $_SESSION['facebook_access_token']); } catch (Facebook\Exceptions\FacebookResponseException $e) { // When Graph returns an error echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch (Facebook\Exceptions\FacebookSDKException $e) { // When validation fails or other local issues echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; } return 'success'; }