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 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题