php - 如何在 PHP 中使用 curl?

标签 php linux curl

<分区>

Possible Duplicate:
get the value of an url response with curl

我有一个名为 stores.php 的 php 页面,现在我想使用 curl 查看此页面的输出,我该怎么做? 到目前为止,我的代码用于 stores.php 页面

<?php


include_once '../application/Boot.php';


if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $body = @file_get_contents('php://input');
    $json = json_decode($body, true);


    if (isset($json['version'])) {
        $client_cache_version =  @$json['version'];

        $sql = $db->quoteInto("SELECT * FROM stores where version_modified > ". $client_cache_version);
        $results = $db->fetchAll($sql);


        $version_sql = $db->quoteInto("SELECT max(version_modified) as version FROM stores");
        $version_results = $db->fetchAll($version_sql);

        $count = array(
            'count' => sizeof($results)
        );

        array_push($results, $version_results['0']);

        array_push($results, $count);
        //ob_start("ob_gzhandler");

        header('HTTP/1.1 200 Stores list');
        echo json_encode($results); 
        exit;

    }else {


        header('HTTP/1.1 400 Bad Request');

        exit;
    }

}else{


    header('HTTP/1.1 400 Bad Request');
    exit;
}

?>

最佳答案

使用 man curl 了解如何使用 curl 显示网页的响应。

例子:

curl "http://www.stackoverflow.com"

关于php - 如何在 PHP 中使用 curl?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8383191/

相关文章:

PHP - Guzzle\Http\Exception\CurlException - Craft CMS

php - Laravel 中需要等效(不存在)whereHour 命令

php - 如何创建一个 "forced"灯箱,即一个 "Pause"屏幕及其背后的内容

php - 如何在 Doctrine 查询构建器中进行多个 WHERE IN 列查询?

linux - 将地址传递给 kfree

python - 如何在使用 Twitter Stream 给出的流示例上暂停、终止、停止或关闭 PycURL 请求

php - 当我尝试获取用户 ID 时它返回空值

c - 如何在makefile.am中添加CFLAGS

linux - 测量程序的网络流量总量

PHP CURL 错误 - curl : (56) Recv failure: Connection reset by peer