dsyct08008 2011-08-05 09:02
浏览 20

使用GoogleViewer在Localhost中显示文档

I have uploaded a few slides on localhost and would like to use googleviewer to display them as it is difficult using php. Is there a library in php which i can possibly use??

Can anyone please tell me how can i use googleviewer to view the documents in my localhost?

Appreciate the help in advance:) Regards Anjana

  • 写回答

1条回答 默认 最新

  • douzao2590 2011-08-05 09:36
    关注
    <?php
    
    /**
     * Retrieve public ip with PHP cURL
     */
    $curl_handle=curl_init();
    curl_setopt($curl_handle,CURLOPT_URL,'http://whatismyip.org/');
    curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
    $public_ip = curl_exec($curl_handle);
    curl_close($curl_handle);
    
    //echo "my ip address is ".$public_ip;
    
    /**
     * Let's say we have the slide located
     * at http://localhost/papers/bigtable-osdi06.ppt
     * The link to view it from google viewer will be
     */
    
     echo 'http://docs.google.com/viewer?url='.urlencode("http://$public_ip/papers/bigtable-osdi06.ppt");
    
    ?>
    

    I retrieve the url with the cURL trick because there isn't a PHP method to let you know your public ip and this way works both in windows or linux as long as http://whatismyip.org/ is up and running.

    Edit:

    Ofcource your web-server has to be accessible from the internet!

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题