doujing5937 2018-05-23 23:11
浏览 52

CURLOPT_USERAGENT为服务器生成令牌

I have installed this php script on one my server "A". It's sending data to the authenticated server "B" 'http://example.com:80/file.php' and the server gives a token that could be used to see the servers content. But the problem is the server "B" is generating token for the server "A" (Network). I can see the server "B" content by using the server "A" token from my computer/android if I use my localhost(xampp) as server "A" but I can't see any content if I put the php script on any HOSTING. I will be glad if anyone gives a solution. Thanks in advance.

<?php
try {
    $ch = curl_init('http://example.com:80/file.php');

//curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: example.com', 'Connection: Keep-Alive', 'Authorization:Basic encrypted-auth'));
    curl_setopt($ch, CURLOPT_USERAGENT, 'Dalvik/2.1.0 (Linux; U; Android 8.0.0; SM-G955F Build/R16NW)');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 0);

    $output = curl_exec($ch);

    if (FALSE === $output) {
        print_r("curl_error:" . curl_error($ch));
        print_r("curl_errno:" . curl_errno($ch));
    }

    curl_close($ch);

    print_r($output);
} catch (Exception $e) {
    print_r($e->getCode());
    print_r($e->getMessage());
}
?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 怎么让wx群机器人发送音乐
    • ¥15 fesafe材料库问题
    • ¥35 beats蓝牙耳机怎么查看日志
    • ¥15 Fluent齿轮搅油
    • ¥15 八爪鱼爬数据为什么自己停了
    • ¥15 交替优化波束形成和ris反射角使保密速率最大化
    • ¥15 树莓派与pix飞控通信
    • ¥15 自动转发微信群信息到另外一个微信群
    • ¥15 outlook无法配置成功
    • ¥30 这是哪个作者做的宝宝起名网站