dongping1689 2013-04-02 11:42
浏览 48

导入XML Google电子表格 - 帮助我使用PHP代码

I came across a requirement to import my DB-Users to a google-spreadsheet.

I did a code with the help of the below instruction. http://www.distilled.net/blog/distilled/guide-to-google-docs-importxml/#chapter4

Now i can get all my DB-Users using the below code.

=importxml("http://mydomain.com/v5/admin/export_google.php","//tr") 

If i paste the above code in a google spreadsheet i can see all my DB-Users in my spreadsheet.

Now, as far as security is concerned

http://mydomain.com/v5/admin/export_google.php -> If i type this url in my browser, then i can see all the db-users.

I need this file to be password protected. Only my client having the code to import the db-users can view my db-users.

Is there a way to keep the file password protected(export_google.php). I know, i can set a username and password at top of my php file but doing that will it won't work if i paste the code in google spreadsheet.

Could someone help me out.

In other words - my client having the code i.e. =importxml("http://mydomain.com/v5/admin/export_google.php","//tr") can take the db-users in google-spreadsheet. Others should not get the information of my db-users using the php file.

  • 写回答

1条回答 默认 最新

  • dongmaomou4117 2015-06-22 08:49
    关注

    You just need to add some GET var to your request and check it inside your script. Like so:

    =importxml("http://example.com/v5/admin/export_google.php?pass=mypass","//tr")
    

    And inside PHP script:

    if (isset($_REQUEST['pass']) && $_REQUEST['pass'] == 'mypass') {
      // your code here
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行