PHP支持HTTPRequest或curl

时间:2017-12-29 02:06:30

标签: php curl

在ubuntu 4.22上运行PHP版本:5.5.9-1 phpinfo()在这里 https://www.gstream.org/api/v2/appnuance2.php

HTTPRequest和curl失败......

提前致谢! 新年快乐!

失败意味着所有控制台消息都显示在函数失败的位置,然后在php传统中 - 没有:-)

我一直在尝试使用HTTPRequest和/或curl向Web服务发出请求。在下面两个初始化对象的情况下,php脚本将失败。我一直在阅读PHP 5.5.9中关于HTTPRequest和curl支持的内容 - 似乎它应该存在。

以下示例代码将在curl_init()

时失败
<div class="blobRegion">    
    <div class="b2_center_view">
        <div class="rows";>
        
                <div class="column">
                    <h3>Some Headline</h3>
                    <p>Paragraph goes here bla bla</p>
                </div>
                
                <div class="column">
                    <h3>Some Headline</h3>
                    <p>Paragraph goes here bla bla</p>
                </div>
                
                <div class="column">
                    <h3>Some Headline</h3>
                    <p>Paragraph goes here bla bla</p>
                </div>
                
                <div class="column">
                    <h3>Some Headline</h3>
                    <p>Paragraph goes here bla bla</p>
                </div>
                
                <div class="column">
                    <h3>Some Headline</h3>
                    <p>Paragraph goes here bla bla</p>
                </div>
                
                <div class="column">
                    <h3>Some Headline</h3>
                    <p>Paragraph goes here bla bla</p>
                </div>
                
                <div class="column">
                    <h3>Some Headline</h3>
                    <p>Paragraph goes here bla bla</p>
                </div>
                
                <div class="column">
                    <h3>Some Headline</h3>
                    <p>Paragraph goes here bla bla</p>
                </div>
                
                <div class="column">
                    <h3>Some Headline</h3>
                    <p>Paragraph goes here bla bla</p>
                </div>
                
                <div class="column">
                    <h3>Some Headline</h3>
                    <p>Paragraph goes here bla bla</p>
                </div>
                
        </div>
    </div>   
</div>

以下代码将在新的HttpRequest()

中失败
/*
 * This function executes the HTTP GET Request for us
 *
 * The HTTP response will be returned to the calling routine
 *
 */
function executeTtsRequest($url)
{
    printf("Inside executeTtsRequest() <br />");
    printf("testing curl <br />");
    printf("url: %s<br />", $url);

    // create curl resource
    printf("Calling curl_init <br />");
    $ch = curl_init();

    // set url
    printf("Calling curl_setopt <br />");
    curl_setopt($ch, CURLOPT_URL, "example.com");

    //return the transfer as a string
    printf("Calling curl_setopt <br />");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    // $output contains the output string
    printf("Calling curl_exec <br />");
    $output = curl_exec($ch);

    // close curl resource to free up system resources
    curl_close($ch);
}

再次感谢 新年快乐!

0 个答案:

没有答案