gpt4 book ai didi

php - curl_init 未定义?

转载 作者:IT王子 更新时间:2023-10-28 23:58:00 26 4
gpt4 key购买 nike

我正在将联系人从 gmail 导入到我的页面......

由于这个错误,进程不工作

'curl_init' is not defined

我得到的建议是

  1. 取消注释 objective-c url.dll
  2. 将以下库复制到 windows/system32 目录:ssleay32.dlllibeay32.dll
  3. 复制php_curl.dll到windows/system32

在尝试了所有这些之后,我刷新了我的 xampp,但即使这样还是会出现错误。

这是我尝试导入 Gmail 联系人的页面:

<?php
resource curl_init ([ string $url = NULL ] )

$ch = curl_init();


curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);


curl_exec($ch);


curl_close($ch);
?>

<?php
echo "hi";

if($_POST['submit'] != '') {
echo "hi";

$clientlogin_url = "https://www.google.com/accounts/ClientLogin";


$clientlogin_post = array(
"accountType" => "HOSTED_OR_GOOGLE",
"Email" => $_POST['Email'],
echo "Passwd" => $_POST['Passwd'],
"service" => "cp",
"source" => "tutsmore/1.2"
);


$curl = curl_init($clientlogin_url);


curl_setopt($curl, CURLOPT_POST, true);


curl_setopt($curl, CURLOPT_POSTFIELDS, $clientlogin_post);


curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);


curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);


curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);


$response = curl_exec($curl);



preg_match("/Auth=([a-z0-9_\-]+)/i", $response, $matches);
$auth = $matches[1];


$headers = array("Authorization: GoogleLogin auth=" . $auth);


$curl = curl_init('http://www.google.com/m8/feeds/contacts/default/full?max-results=10000');


curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);


curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);


$feed = curl_exec($curl);


echo "contacts".$contacts=array();


$doc=new DOMDocument();



if (!empty($feed)) $doc->loadHTML($feed);


$xpath=new DOMXPath($doc);


$query="//entry";
$data=$xpath->query($query);

foreach ($data as $node) {


$entry_nodes=$node->childNodes;


$tempArray=array();


foreach($entry_nodes as $child) {


$domNodesName=$child->nodeName;

switch($domNodesName) {
case 'title' : {
$tempArray['fullName']=$child->nodeValue;
} break
;
case 'email' : {
if (strpos($child->getAttribute('rel'),'home')!==false)
$tempArray['email_1']=$child->getAttribute('address');
elseif(strpos($child->getAttribute('rel'),'work')!=false)
$tempArray['email_2']=$child->getAttribute('address');
elseif(strpos($child->getAttribute('rel'),'other')!==false)
$tempArray['email_3']=$child->getAttribute('address');
} break
;
}
}
if (!empty($tempArray['email_1']))$contacts[$tempArray['email_1']]=$tempArray;
if(!empty($tempArray['email_2'])) $contacts[$tempArray['email_2']]=$tempArray;
if(!empty($tempArray['email_3'])) $contacts[$tempArray['email_3']]=$tempArray;
}
foreach($contacts as $key=>$val) {

echo $key."<br/>";
}
}
else {

?>
<form action="<?=$PHP_SELF?>" method="POST">
<table>
<tr>
<td>Email:</td><td><input type="text" name="Email" /></td>
</tr>
<tr>
<td>Password:</td><td><input type="password" name="Passwd" /></td>
</tr>
<tr><td colspan="2" align="center">tutsmore don't save your email and password trust us.</td></tr>
<tr><td colspan="2" align="center"><input type="submit" name="submit" value="Get Contacts" /></td></tr>
</table>
</form>
<?php
}
?>

此代码完全用于调试;如果需要任何优化,我会尝试优化代码。

最佳答案

要使用 php 安装 curl,只需键入命令

sudo apt-get install php5-curl

安装 php 之后

关于php - curl_init 未定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2997040/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com