小编Bon*_*nny的帖子

从php文件调用JSON到HTML页面

我正在制作一个需要显示视频的html页面.视频的网址在jsondecode输出中找到.有没有办法从该JSON输出中选择片段并在我的html页面中使用它?我已经尝试过POST和GET和echo,但似乎没有用.

要明确:我正试图从php文件到单独的HTML文件.

JSON反应是在功能的单独的文件中.

public function getURL(){
    $server_url= ilObjPresentations2GoGUI::getServerUrl();
     $secret_key= ilObjPresentations2GoGUI::getSecretKey();
     $authorized_group= ilObjPresentations2GoGUI::getAuthorizedGroup();
     $link_usable= ilObjPresentations2GoGUI::getLinkUsable();
     $query = 'technology';

    $date = new DateTime('NOW');
    $ts = $date->format('Y-m-d\TH:i:s');
    $interval = 'PT' . $this->link_usable . 'H';
    $date->add(new DateInterval('PT' . $link_usable . 'H'));
    $expired = $date->format('Y-m-d\TH:i:s');
    $url = $server_url . '?action=search&query='. $query . '&group='. $authorized_group . '&ts=' . $ts . '&expired=' .$expired; 

    $token = ilObjPresentations2GoAPI::create($url,$secret_key);
    $goodurl = $url . '&token=' . $token;

    $json = file_get_contents($goodurl);
    $the_data = json_decode($json, true);}
Run Code Online (Sandbox Code Playgroud)

输出: …

html php json

2
推荐指数
1
解决办法
109
查看次数

标签 统计

html ×1

json ×1

php ×1