【问题标题】:Creating transparent background on skype buttons在 Skype 按钮上创建透明背景
【发布时间】:2012-06-17 15:25:23
【问题描述】:

我正在按照本教程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 的文件夹中。

谁能帮忙

【问题讨论】:

  • 除了这个getSkypeStatus函数写得很好之外:尝试从浏览器打开该网页的源代码,看看HTML是否正确。
  • 你还有其他解决方案吗?

标签: php html fopen skype


【解决方案1】:

要添加点击通话功能,请使用&lt;a&gt; 标签:

<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 的回答在这个问题上给了你一些很好的提示。

【讨论】:

    【解决方案2】:

    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 之类的浏览器访问该图像,并且您能够看到它,则问题与未给出预期 0 到 7 值的 $status 有关。

    【讨论】:

    • @zull 图片链接运行良好,我使用的是来自我网站的直接链接,它在浏览器中显示所有图片,所以我不确定问题出在哪里,但正如您所建议的那样与 $status 相关的是否有解决此问题的方法?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-01
    • 2021-05-20
    • 2015-02-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多