0

我正在关注本教程http://www.jek2k.com/wp/2008/02/08/building-a-custom-skype-me-button-with-status-icon/在我的网站上获取透明的 Skype 按钮所以人们可以通过点击一个按钮给我打电话。Skype 有自己的但是背景是白色的,http://www.skype.com/intl/en-us/tell-a-friend/get-a-skype-button/

我的代码是:

          <?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 myusernamehere'。没有图像,我无法单击此处呼叫 myusername 以打开 Skype 和呼叫。

我已将图像 0-7 插入到我的根文件夹中名为 skype 的文件夹中。

谁能帮忙

4

2 回答 2

0

要添加点击通话功能,请使用以下<a>标签:

<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');

图片未显示的问题与此代码无关。Zuul 的回答在这个问题上给了你一些很好的提示。

于 2012-06-14T15:17:40.550 回答
0

1)

该问题与可能未正确构建的图像路径有关,或者它本身的图像不存在于指定位置,因为浏览器正在呈现该alt属性。

在此处指定 Skype 图像路径:

echo '<img src="/skype/'.$status.'.png" alt="call '.$username.'" />';

找不到图像时的输出是call '.$username.'alt属性提供的内容。

当我在我的网站上进行测试时,它就会出现:'call myusernamehere'。

您可以使用 DOM 检查器工具(例如 Firebug)来确认属性中指定的图像路径src是否正确构建。

2)

如果您通过浏览器访问图像http://www.mysite.com/skype/1.png,并且您能够看到它,则问题与$status没有给出预期的 0 到 7 值有关。

于 2012-06-14T15:13:45.063 回答