Php 在skype按钮上创建透明背景
我遵循本教程,在我的网站上获得透明的skype按钮,这样人们只需点击一个按钮就可以给我打电话。Skype有自己的背景,但背景是白色的 我的代码是:Php 在skype按钮上创建透明背景,php,html,fopen,skype,Php,Html,Fopen,Skype,我遵循本教程,在我的网站上获得透明的skype按钮,这样人们只需点击一个按钮就可以给我打电话。Skype有自己的背景,但背景是白色的 我的代码是: <?php function getSkypeStatus($username) { /* returns: 0 - unknown 1 - offline 2 - online 3 - away 4 - not available 5 - do not dis
<?php
function getSkypeStatus($username) {
/*
returns:
0 - unknown
1 - offline
2 - online
3 - away
4 - not available
5 - do not disturb
6 - invisible
7 - skype me
*/
$remote_status = fopen ('http://mystatus.skype.com/'.$username.'.num', 'r');
if (!$remote_status) {
return '0';
exit;
}
while (!feof ($remote_status)) {
$value = fgets ($remote_status, 1024);
return trim($value);
}
fclose($remote_status);
}
function getSkypeStatusIcon($username) {
$status = getSkypeStatus($username);
// change the path of the icons folder to match your site
echo '<img src="/skype/'.$status.'.png" alt="call '.$username.'" />';
}
// retrieves the numeric status code
//getSkypeStatus('nicolovolpato');
// displays the status icon, change to match your Skype username
getSkypeStatusIcon('myusernamehere');
?>
当我在我的网站上测试这一点时,它只会出现:“在这里调用我的用户名”。没有图像,我无法单击call MyUserName此处打开skype并呼叫
我已将图像0-7插入根文件夹中名为skype的文件夹中
有人能帮忙吗1
该问题与可能未正确构造的图像路径有关,或者由于浏览器显示alt属性,因此图像本身不在指定位置
在此处指定Skype映像路径:
找不到图像时的输出是调用“%$username.”,其中包含为alt属性指定的内容
当我在我的网站上测试这一点时,它只会出现:“在这里调用我的用户名”
您可以使用DOM检查器工具(例如Firebug)来确认在src属性处指定的图像路径是否正确构造
2.
如果您通过类似浏览器的方式访问图像http://www.mysite.com/skype/1.png,您可以看到,问题与$status有关,该$status没有给出预期的0到7值。要添加点击呼叫功能,请使用标记: 因此,此脚本的修改版本如下所示:
<?php
function getSkypeStatus($username) {
$remote_status = file_get_contents('http://mystatus.skype.com/'. $username .'.num');
return ($remote_status === false) ? '0' : trim($remote_status);
}
function showSkypeButton($username) {
$status = getSkypeStatus($username);
echo '<a href="skype:'. $username .'?call">';
echo '<img src="/skype/'. $status .'.png" alt="Call '. $username .'">';
echo '</a>';
}
showSkypeButton('whatever');
图像未显示的问题与此代码无关。Zuul的回答在这个问题上给了你一些很好的提示。除了这个getSkypeStatus函数写得很好之外:试着从浏览器打开该网页的源代码,看看HTML是否正确。你还有其他解决方案吗?@zull图像链接工作正常,我使用的是来自我网站的直接链接,它在浏览器中显示所有图像,因此我不确定问题出在哪里。但是,正如您所建议的,它与$status有关。是否有解决方法?
<a href="skype:{username}?call">...</a>
<?php
function getSkypeStatus($username) {
$remote_status = file_get_contents('http://mystatus.skype.com/'. $username .'.num');
return ($remote_status === false) ? '0' : trim($remote_status);
}
function showSkypeButton($username) {
$status = getSkypeStatus($username);
echo '<a href="skype:'. $username .'?call">';
echo '<img src="/skype/'. $status .'.png" alt="Call '. $username .'">';
echo '</a>';
}
showSkypeButton('whatever');