curl_init undefined?
Posted
by udaya
on Stack Overflow
See other posts from Stack Overflow
or by udaya
Published on 2010-06-08T12:00:47Z
Indexed on
2010/06/08
12:02 UTC
Read the original article
Hit count: 413
Hi
I am importing the contacts from gmail to my page .....
The process doesnot work due to this error
'curl_init'
is not defined
The suggestion i got is to
1.uncomment destination curl.dll
2.copy the following libraries to the windows/system32 dir.
ssleay32.dll
libeay32.dll
3.copy php_curl.dll to windows/system32
After trying all these i refreshed my xampp
Even then error occurs
This is my page where i am trying to import the gmail contacts
`
// set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "http://www.example.com/"); curl_setopt($ch, CURLOPT_HEADER, 0);
// grab URL and pass it to the browser curl_exec($ch);
// close cURL resource, and free up system resources curl_close($ch); ?>
"HOSTED_OR_GOOGLE", "Email" => $_POST['Email'], echo "Passwd" => $_POST['Passwd'], "service" => "cp", "source" => "tutsmore/1.2" );
//Now we are going to post these datas to the clientLogin url. // Initialize the curl object with the $curl = curl_init($clientlogin_url);
//Make the post true curl_setopt($curl, CURLOPT_POST, true);
//Passing the above array of parameters. curl_setopt($curl, CURLOPT_POSTFIELDS, $clientlogin_post);
//Set this for authentication and ssl communication. curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
//provide false to not to check the server for the certificate. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
//Tell curl to just don't echo the data but return it to a variable. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
//The variable containing response $response = curl_exec($curl);
//Check whether the user is successfully login using the preg_match and save the auth key if the user //is successfully logged in preg_match("/Auth=([a-z0-9_-]+)/i", $response, $matches); $auth = $matches[1];
// Include the Auth string in the headers $headers = array("Authorization: GoogleLogin auth=" . $auth);
// Make the request to the google contacts feed with the auth key $curl = curl_init('http://www.google.com/m8/feeds/contacts/default/full?max-results=10000');
//passing the headers of auth key. curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
//Return the result in a variable curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
//the variable with the response. $feed = curl_exec($curl);
//Create empty array of contacts echo "contacts".$contacts=array();
//Initialize the DOMDocument object $doc=new DOMDocument();
//Check whether the feed is empty //If not empty then load that feed. if (!empty($feed)) $doc->loadHTML($feed);
//Initialize the domxpath object and provide the loaded feed $xpath=new DOMXPath($doc);
//Get every entry tags from the feed. $query="//entry"; $data=$xpath->query($query); //Process each entry tag foreach ($data as $node) {
//children of each entry tag. $entry_nodes=$node->childNodes;
//Create a temproray array. $tempArray=array();
//Process the child node of the entry tag. foreach($entry_nodes as $child) {
//get the tagname of the child node. $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 the email
echo $key."
";
}
}
else
{
//The form
?>
` code is completely provided for debugging if any optimization is needed i will try to optimize the code
© Stack Overflow or respective owner