【问题标题】:Embebed player can't connect to the network - CURL嵌入式播放器无法连接到网络 - CURL
【发布时间】:2012-10-15 16:13:54
【问题描述】:

我已经使用 CURL 制作了登录到提供免费流媒体的页面的脚本,然后使用 CURL 我将使用所选流转到子页面来观看。

脚本通过 localhost 运行时一切正常(我使用的是 xampp),但是当我将它放在我的网络服务器上时,它说它无法连接到网络。唯一看起来不同的是 cookie,在 Web 服务器上它没有新行 /n。一切都在一条线上。

如何处理?这是我的课程,我用它来连接页面:

class openTV {

public $channel;

function __construct($channel) {
    $this -> channel = $channel;    
}

function openChannel() {

    $login_email = 'mail@gmail.com';
    $login_pass = 'pass';

    $fp = fopen("cookie.txt", "w");
    fclose($fp); 

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'http://strona/user/login');
    curl_setopt($ch, CURLOPT_POSTFIELDS,'email='.urlencode($login_email).'&password='.urlencode($login_pass));
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
    curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
    curl_setopt($ch, CURLOPT_REFERER, "http://strona/user/login");
    $page = curl_exec($ch);

    curl_setopt($ch, CURLOPT_URL, $this->channel);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
    curl_setopt($ch, CURLOPT_REFERER, $this->channel);
    curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
    curl_setopt($ch, CURLOPT_POST, 0);
    $info = curl_getinfo ($ch);
    $page = curl_exec($ch);

    preg_match('/session_token=\[[a-zA-Z0-9]{8}\]/', $page, $matches);
    $return['token'] = substr($matches[0], 31, 8); 

    preg_match('/<object(.*)>[.\s\S]*<\/object>/', $page, $matches);
    $return['player'] = $matches[0];
    //$return['player'] = $page;

    $return['channel'] = $this->channel;

    return $return;

}

}

【问题讨论】:

    标签: php flash curl streaming media-player


    【解决方案1】:

    您正在使用http://strona/ 作为您的主机。

    您的服务器可能使用了不同的配置,当它无法直接找到主机时,它不会尝试附加 .example.com,在 Linux 上可以看到 /etc/resolve.conf

    search example.com
    nameserver 1.2.3.4
    

    使用完整的域名 (http://strona.example.com) 或 IP 应该可以解决问题。

    如果不是这样,请尝试是否能够从服务器 ping(或以其他方式连接)到目标主机,这可能是网络问题。

    【讨论】:

    • 好吧,我把'strona'放在那里只是作为例子,最初有wlacz.tv,但仍然没有工作。但可以通过 localhost 完美运行。
    • 维克托是什么意思?有没有办法解决这个问题?
    • @user1648759 还有另一个堆栈交换站点:serverfault.com
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-16
    • 1970-01-01
    • 2011-06-18
    • 2015-05-20
    相关资源
    最近更新 更多