Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Developers

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-01-2008, 12:35 PM
Loyal Member
 
Posts: 97
Default PHP Curl Preauth Code

I finally got it working, the standard ways would not work. Here is what finally worked. I'm sure half of it could be trimmed out, if someone wants to optimize this please post the code back here.

This was with php 5.2.4. There are some issues with curl and open_dirs and safe mode in php. If you look at the php documentation you will see it.


PHP Code:
<?php
        $zimbra_email_id 
="123456"// you need to know the id of the eamil to extract it.
        
$zm_base_url "http://zimbra.example.com";
         
$zm_redirect_url "/?id=".$zimbra_email_id."&view=html";
         
$zimbra_user "zimbra_user";
         
//I have a group of functions that will build this, but I don't have time to post it now.
         //but the url should look like this.
         
         //  http://zimbra.example.com/service/preauth?account=zimbra_user&expires=0&timestamp=1201897639000&preauth=14464oeu51ca6baaoeuaoeuaoeu368foeu1135d3e1&redirectURL=/zimbra/home/zimbra_user/?id=41452&view=html
         
$zm_url ="" ;//$obj->build_preauth_url($zm_base_url,$zm_redirect_url);
        
           
$ch curl_init();
        
          
$header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
          
$header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
          
$header[] = "Cache-Control: max-age=0";
          
$header[] = "Connection: keep-alive";
          
$header[] = "Keep-Alive: 300";
          
$header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
          
$header[] = "Accept-Language: en-us,en;q=0.5";
          
$header[] = "Pragma: "// browsers keep this blank.
          
curl_setopt($chCURLOPT_URL$zm_url);
          
curl_setopt($chCURLOPT_USERAGENT'Googlebot/2.1 (+http://www.google.com/bot.html)');
          
curl_setopt($chCURLOPT_HTTPHEADER$header);
          
curl_setopt($chCURLOPT_REFERER'http://www.google.com');
          
curl_setopt($chCURLOPT_ENCODING'gzip,deflate');
          
curl_setopt($chCURLOPT_AUTOREFERERtrue);
          
curl_setopt($chCURLOPT_RETURNTRANSFER1);
          
curl_setopt($chCURLOPT_TIMEOUT10);
          
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
          
curl_setopt($chCURLOPT_FAILONERROR1);
          
curl_setopt ($chCURLOPT_COOKIEJAR"cookies");  
          
curl_setopt($chCURLOPT_COOKIEFILE'cookie'.$zimbra_user.'.txt');
          
//  curl_setopt($ch, CURLOPT_HTTPGET, 1); //might be of value
        // curl_setopt($ch, CURLOPT_REFERER,1);
          
          
          
$html curl_exec($ch); // execute the curl command 
          
echo $html;


?>
__________________
EricX
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.