从命令行(PHP)点击网站上的“播放”按钮

时间:2014-04-26 08:13:20

标签: php command-line webautomation

我在我的机器上使用Ampache(基于网络的音乐播放器),我正在尝试自动化 “play_democratic”函数在下面的代码中以粗体列出。

此功能只播放音乐(看起来像网页上的播放按钮) 但是我希望通过命令行(xubuntu 13.10)

执行该功能

所以它看起来像这样

`sudo php show_democratic.inc.php play_democratic`

注意,网站使用身份验证,因此我不确定如何将该信息传递到命令行,或者我是否需要创建shell脚本来执行该功能。

我正在运行xubuntu 13.10

请参阅下面的完整PHP文件内容。

<?php
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* Copyright 2001 - 2013 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*
*/

$string = $democratic->is_enabled() ? sprintf(T_('%s Playlist') ,$democratic->name) :   T_('Democratic Playlist');
UI::show_box_top($string , 'info-box');
?>
<div id="information_actions">
<ul>
<?php if ($democratic->is_enabled()) { ?>
<li>
<?php echo T_('Cooldown'); ?>:<?php echo $democratic->f_cooldown; ?>
</li>
<?php } ?>
<?php if (Access::check('interface','75')) { ?>
<li>
<a href="<?php echo AmpConfig::get('web_path');
?>/democratic.php?action=manage"><?php  echo UI::get_icon('server_lightning', 
T_('Configure Democratic Playlist')); ?></a>
<?php echo T_('Configure Democratic Playlist'); ?>
</li>
<?php if ($democratic->is_enabled()) { ?>
<li>
<?php echo Ajax::button('?page=democratic&action=send_playlist&democratic_id=' .
scrub_out($democratic->id),'all', T_(**'Play'),'play_democratic'); ?>**
<?php echo T_('Play Democratic Playlist'); ?>
</li>
<li>
<?php echo Ajax::button('?page=democratic&action=clear_playlist&democratic_id=' . 
scrub_out($democratic->id),'delete', T_('Clear Playlist'),'clear_democratic'); ?>
<?php echo T_('Clear Playlist'); ?>
</li>
<?php } ?>
<?php } ?>
</ul>

</div>
<?php UI::show_box_bottom(); ?>

1 个答案:

答案 0 :(得分:0)

如果您尝试从命令行与Web应用程序进行交互,则无需修改Web应用程序代码。您只需通过命令行实用程序(如cUrl。

)调用URL