getJSON() public method

Get all information about a video.
public getJSON ( string $url, string $format = null ) : object
$url string URL of page
$format string Format to use for the video
return object Decoded JSON
Example #1
0
 /**
  * Output JSON info about the video.
  *
  * @param Request  $request  PSR-7 request
  * @param Response $response PSR-7 response
  *
  * @return Response HTTP response
  */
 public function json(Request $request, Response $response)
 {
     $params = $request->getQueryParams();
     if (isset($params['url'])) {
         try {
             $video = $this->download->getJSON($params['url']);
             return $response->withJson($video);
         } catch (\Exception $e) {
             return $response->withJson(['success' => false, 'error' => $e->getMessage()]);
         }
     }
 }
Example #2
0
 /**
  * Test getJSON function errors.
  *
  * @param string $url URL
  *
  * @return void
  * @expectedException Exception
  * @dataProvider      ErrorURLProvider
  */
 public function testGetJSONError($url)
 {
     $videoURL = $this->download->getJSON($url);
 }
Example #3
0
 /**
  * Output JSON info about the video
  * @return void
  */
 static function json()
 {
     global $app;
     if (isset($_GET["url"])) {
         $app->response->headers->set('Content-Type', 'application/json');
         try {
             $video = VideoDownload::getJSON($_GET["url"]);
             echo json_encode($video);
         } catch (\Exception $e) {
             echo json_encode(array('success' => false, 'error' => $e->getMessage()));
         }
     }
 }
 /**
  * Test getJSON function errors
  *
  * @param string $url URL
  *
  * @return            void
  * @expectedException Exception
  * @dataProvider      ErrorURLProvider
  */
 public function testGetJSONError($url)
 {
     $videoURL = VideoDownload::getJSON($url);
 }