we have a DITA XML application that produces on the fly xhtml and when viewed in the browser it looks fine.

我们有一个DITA XML应用程序,它可以即时生成xhtml,在浏览器中查看它看起来很好。

An example url is: http://livecontent.jordanpublishing.co.uk/content/en/FAMILY-201103311115/Family_FLJONLINE_FLJ_2009_07_4

一个示例网址是:http://livecontent.jordanpublishing.co.uk/content/en/FAMILY-201103311115/Family_FLJONLINE_FLJ_2009_07_4

If I try to load the url using curl I get the following error:

如果我尝试使用curl加载url,我会收到以下错误:

Error checking function parameter 3 in call transform:transform($fDoc, LiveContent-UI:get_xsl("ui/ui_skin.xsl", ""), LiveContent-UI:get_xsl_params(untyped-value-check[xs:string, $skin], $extra_params)): The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: LiveContent-Util:browser_from_user_agent($a as xs:string) xs:string. Expected cardinality: exactly one, got 0.

XQuery Stack TraceLiveContent-Util:browser_from_user_agent(xs:string)   161:55
LiveContent-UI:get_xsl_params(xs:string, node())    145:25
LiveContent-UI:get_html(xs:string, xs:string, node(), node())   313:25
LiveContent-Pub:home(xs:string, xs:string, xs:string)   65:17
Java Stack Trace:Class Name Method Name File Name   Line
org.exist.xquery.DynamicCardinalityCheck    eval    DynamicCardinalityCheck.java    80
org.exist.xquery.Atomize    eval    Atomize.java    66
org.exist.xquery.UntypedValueCheck  eval    UntypedValueCheck.java  75
org.exist.xquery.DynamicTypeCheck   eval    DynamicTypeCheck.java   61
org.exist.xquery.FunctionCall   eval    FunctionCall.java   185
org.exist.xquery.AbstractExpression eval    AbstractExpression.java 61
org.exist.xquery.PathExpr   eval    PathExpr.java   241
org.exist.xquery.AttributeConstructor   eval    AttributeConstructor.java   95
org.exist.xquery.ElementConstructor eval    ElementConstructor.java 212
org.exist.xquery.AbstractExpression eval    AbstractExpression.java 61
org.exist.xquery.PathExpr   eval    PathExpr.java   241
org.exist.xquery.ElementConstructor eval    ElementConstructor.java 271
org.exist.xquery.AbstractExpression eval    AbstractExpression.java 61
org.exist.xquery.PathExpr   eval    PathExpr.java   241
org.exist.xquery.DebuggableExpression   eval    DebuggableExpression.java   56
org.exist.xquery.DebuggableExpression   eval    DebuggableExpression.java   63
org.exist.xquery.LetExpr    eval    LetExpr.java    208
org.exist.xquery.BindingExpression  eval    BindingExpression.java  158
org.exist.xquery.AbstractExpression eval    AbstractExpression.java 61
org.exist.xquery.PathExpr   eval    PathExpr.java   241

and I am completely at a loss as to what is going wrong.

我完全不知道出了什么问题。

The PHP Curl code is as follows:

PHP Curl代码如下:

$ch = curl_init();
/**
* Set the URL of the page or file to download.
*/
curl_setopt($ch, CURLOPT_URL, 'http://onlineservices.letterpart.com/sitemap.xml;jsessionid=1j1agloz5ke7l?id=1j1agloz5ke7l');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec ($ch);
curl_close ($ch);

$xml = new SimpleXMLElement($data);
foreach ($xml->url as $url_list) {
    $url = $url_list->loc;
    echo $url ."<br>"; 
    //file_get_contents($url);




    echo $url ."<br>";   
    $ch = curl_init($url); //load the urls
                    echo $url ."<br>";  
            curl_setopt($ch, CURLOPT_TIMEOUT_m2, 20); //No need to wait for it to load. Execute it and go.
            curl_exec($ch); //Execute
            curl_close($ch); //Close it off 

Can anyone help? I'm at a bit of a loss as this is way outside of my skill set.

有人可以帮忙吗?我有点失落,因为这超出了我的技能范围。

Thanks,

EDIT:

It was suggested that I added a User Agent so I added the following:

有人建议我添加了一个用户代理,所以我添加了以下内容:

curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");

curl_setopt($ ch,CURLOPT_USERAGENT,“Mozilla / 4.0(兼容; MSIE 5.01; Windows NT 5.0)”);

I now get the following error in my logs:

我现在在日志中收到以下错误:

[13-May-2011 16:30:14] PHP Notice:  Use of undefined constant CURLOPT_TIMEOUT_m2 - assumed 'CURLOPT_TIMEOUT_m2' in /home/digital1/public_html/dev/sitemap.php on line 43
[13-May-2011 16:30:14] PHP Warning:  curl_setopt() [<a href='function.curl-setopt'>function.curl-setopt</a>]: Invalid curl configuration option in /home/digital1/public_html/dev/sitemap.php on line 43

The two line in question here (43) is:

这里讨论的两条线(43)是:

curl_setopt($ch, CURLOPT_TIMEOUT_m2, 20); //No need to wait for it to load. Execute it and go.

I do seem to be having better luck using the Googlebot agent:

我似乎使用Googlebot代理有更好的运气:

Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)

as in I am actually getting content written to the screen but my logs are still showing these errors.

就像在我实际上将内容写入屏幕但我的日志仍然显示这些错误。

1 个解决方案

#1


3

My immediate guess is that your Java app is expecting the User-Agent header to be set. Since Curl does not send a User-Agent header by default, you will need to set one. Try adding this above your option to set CURL_TIMEOUT_m2.

我的直接猜测是你的Java应用程序期望设置User-Agent标头。由于Curl默认情况下不发送User-Agent标头,因此您需要设置一个。尝试在选项上方添加此选项以设置CURL_TIMEOUT_m2。

curl_setopt($ch, CURLOPT_USERAGENT, "PHP/".PHP_VERSION );

If for some reason it does not like that User-Agent string, you might want to try using one from an actual browser.

如果由于某种原因它不喜欢User-Agent字符串,您可能想尝试使用实际浏览器中的一个。

EDIT:

Per your edit, this is because you've typoed the curl timeout constant. It should be CURLOPT_TIMEOUT_MS not CURLOPT_TIMEOUT_m2.

根据您的编辑,这是因为您已经错误地卷曲了卷曲超时常量。它应该是CURLOPT_TIMEOUT_MS而不是CURLOPT_TIMEOUT_m2。

更多相关文章

  1. Yourphp系统发生错误
  2. 在PHP中,为什么没有显示解析错误?
  3. phpnow1.5.6如何设置404错误页面?
  4. php异常和错误处理
  5. APMServ 在 Win7 下出现“APMServ-Apache 服务因 函数不正确。
  6. 从。net调用Magento API,并得到“位于XYZ的HTTP服务太忙”的错误
  7. 我得到了“致命错误:未捕获的SoapFault异常:[客户机]SoapClient:
  8. ajax php bomt头 utf-8带来的奇怪问题。。返回值false 判断也是f
  9. 编译php时遇到的错误

随机推荐

  1. Android中使用Gallery_tabhost来实现标签
  2. alps/frameworks/base/wifi/java/android
  3. Android APK 打包
  4. 与spinner有关的样式
  5. android短信和彩信探秘threads
  6. android音乐播放器常见操作
  7. android 获取 imei号码以及其他信息
  8. Android(安卓)程序中哪个 Activity 最先
  9. Android使用代码
  10. Android三种方法设置ImageView的图片