0
我使用這個簡單示例http://wiki.developerforce.com/index.php/Simple_Web2Lead_Implementation測試Salesforce的WebToLead表單。爲什麼fsockget在這個例子中對某些文本使用單引號時超時?
當我改變了雙引號(用來連接的$header
值)爲單引號,我不斷收到以下錯誤:
Fatal error: Maximum execution time of 60 seconds exceeded in C:\wamp\www\test.php on line 23
當我改回雙引號,一切工作正常。我錯過了什麼?
下面是一個簡化版本,你可以使用,如果你有一個Salesforce的開發者帳戶:
<?php
//do quality checks on the incoming data here.
//then bundle the request and send it to Salesforce.com
$req = "&lead_source=". urlencode("test");
$req .= "&first_name=" . urlencode("first name test");
$req .= "&debug=" . urlencode("1");
$req .= "&oid=" . urlencode("<your oid>");
$req .= "&retURL=" . "";
$req .= "&debugEmail=" . urlencode("<your email>");
$header = 'POST /servlet/servlet.WebToLead?encoding=UTF-8 HTTP/1.0\r\n';
$header .= 'Content-Type: application/x-www-form-urlencoded\r\n';
$header .= 'Host: www.salesforce.com\r\n';
$header .= 'Content-Length: ' . strlen($req) . '\r\n\r\n';
$fp = fsockopen ('www.salesforce.com', 80, $errno, $errstr, 30);
if (!$fp) {
echo "No connection made";
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024); // error is thrown here
echo $res;
}
}
fclose($fp);
?>
猜想我錯過了'注意:與雙引號和heredoc語法不同,特殊字符的變量和轉義序列在單引號字符串中出現時不會被擴展.'當查看http://php.net/manual /en/language.types.string.php – Omar