balasun Posted April 10, 2009 Share Posted April 10, 2009 Hello, I used to access another site data using PHP ,curl. The access is working well. But the After access redirection to my site does not takes place.. My code is as follows: class test { var $login = ""; /** * LinkedIn Account Password * @public * @var string */ var $password = ""; /** * Sets the output format * - For Array format : array * - For XML format : xml * - Default : array * @public * @var string */ var $outputFormat = "array"; // var $outputFormat = "xml"; /** * Abosolute path to save the cookie * Default value is DOCUMENT_ROOT * @public * @var string */ var $cookieJarPath = ""; /** * Abosulte path to the CA Bundle file * SSL Certificate required to verify CA cert * Usually required when script ran on Localhost * Remote servers may not require * Default value is false * @public * @var string */ var $caBundleFile = ""; /** * Specifies if Proxy server required as Gateaway * Default value is false * @public * @var boolean */ var $isUsingProxy = false; /** * Proxy host name * @public * @var string */ var $proxyHost = ""; /** * Proxy port number * @public * @var int */ var $proxyPort = 0; /*------------------------------------------------------- Private Variables -------------------------------------------------------*/ /** * URL to Authenticate user on LinkedIn * @private * @var string */ var $authUrl = "https://www.linkedin.com/secure/login"; /** * URL for the desired Service * @private * @var string */ //var $serviceUrl = "http://www.linkedin.com/addressBookExport"; // var $serviceUrl = "http://www.linkedin.com/connections?trk=hb_side_cnts"; var $serviceUrl = ""; /** * User agent (used to trick LinkedIn) * @private * @var string */ var $userAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3"; /** * Referer URL (used to trick LinkedIn) * @private * @var string */ var $referer = "http://www.linkedin.com"; /** * Specifies whether output includes the header * @private * @var int */ var $showHeader = 0; /** * Specifies if cURL should follow the redirected URL * @private * @var int */ var $follow = 0; /** * Specifies if cURL should return the output as string * @private * @var int */ var $returnTransfer = 1; /** * Specifies if cURL should verify peer certificate * @private * @var int */ var $sslVerifyPeer = 0; /** * Specifies number of post fields to pass * @private * @var int */ var $numPostField = 0; /** * Specify fields to send via POST method as key=value * @private * @var string */ var $postFields = ""; /** * File where output is temporarily saved during authentication * @private * @var string */ var $authOutputFile = ""; /** * File where service output is temporarily saved * @private * @var string */ var $outputFile = ""; /** * File where Cookie is temporarily saved * @private * @var string */ var $cookieFileJar = ""; /** * Cookie File that is read by service process * This carries same value as $cookieFileJar * @private * @var string */ var $cookieFile = ""; /** * Specifies if Cookie is to be in header * @private * @var int */ var $cookie = 0; /** * Proxy address as proxy.host:port * @private * @var string */ var $proxy = ""; /** * Error Information set by either cURL or Internal process * @private * @var string */ var $errorInfo = ""; /** * Output of Contact List * @private * @var array */ var $list = array(); function setCurlOption() { // Sets the User Agent curl_setopt($this->curlSession, CURLOPT_USERAGENT, $this->userAgent); curl_setopt($this->curlSession, CURLOPT_FOLLOWLOCATION, true); curl_setopt($this->curlSession, CURLOPT_BINARYTRANSFER, 0); // Sets the HTTP Referer curl_setopt($this->curlSession, CURLOPT_REFERER, $this->referer); // Sets the URL that PHP will fetch using cURL curl_setopt($this->curlSession, CURLOPT_URL, $this->url); // Sets the number of fields to be passed via HTTP POST curl_setopt($this->curlSession, CURLOPT_POST, $this->numPostField); // Sets the fields to be sent via HTTP POST as key=value curl_setopt($this->curlSession, CURLOPT_POSTFIELDS, $this->postFields); //curl_setopt($this->curlSession, CURLOPT_FOLLOWLOCATION, 1); // curl_setopt($this->curlSession, CURLOPT_RETURNTRANSFER, 1); // Sets the filename where cookie information will be saved // curl_setopt($this->curlSession, CURLOPT_COOKIEJAR, $this->cookieFileJar); // Sets the filename where cookie information will be looked up //curl_setopt($this->curlSession, CURLOPT_COOKIEFILE, $this->cookieFile); // Sets the option to set Cookie into HTTP header // curl_setopt($this->curlSession, CURLOPT_COOKIE, $this->cookie); // Checks if the user needs proxy (to be set by user) if ($this->isUsingProxy) { // Checks if the proxy host and port is specified if ((empty($this->proxyHost)) || (empty($this->proxyPort))) { $this->setError("proxy_required"); $this->unlinkFile($this->cookieFileJar); return false; } // Sets the proxy address as proxy.host:port $this->proxy = $this->proxyHost . ":" . $this->proxyPort; } // Sets the proxy server as proxy.host:port curl_setopt($this->curlSession, CURLOPT_PROXY, $this->proxy); // Sets the filename where output will be temporarily saved //Prob // curl_setopt($this->curlSession, CURLOPT_RETURNTRANSFER, $this->returnTransfer); // Sets to false if the authentication URL is a secured server address // curl_setopt($this->curlSession, CURLOPT_SSL_VERIFYPEER, $this->sslVerifyPeer); // curl_setopt($this->curlSession, CURLOPT_FOLLOWLOCATION, $this->follow); return true; } } Pls help me to do redirection to my site after access.. Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/153506-help-me-in-php-curl/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.