Jump to content
php.lv forumi

cURL


waplet

Recommended Posts

Meklēju google kā arī lv.php.net/cUrl.. bet neko neatradu par sesijām..

Vai ir iespējams.. nosūtīt POST vai GET .. ielogoties, saņemt to sesiju un ar to sesiju tālāk darīt visādas lietas?

Link to comment
Share on other sites

protams ka ir :)

 

piem vari uploadot failus

 

$ch = curl_init();

$data = array('name' => 'Foo', 'file' => '@/home/user/test.png');

curl_setopt($ch, CURLOPT_URL, 'http://localhost/upload.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

curl_exec($ch);

 

kurla darbojās aptveni šādi

 

<?
// uzsakam sesiju
$ch = curl_init();[/color]



// urla kur iesim
curl_setopt($ch,CURLOPT_URL,'http://php.lv/f');


// ja gribi sanjemt atpakaļ saturu piemet klat RETURNTRANSFER

curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);

// un palaid
$e = curl_exec($ch);
curl_close($ch);
?>

 

es te nesen biju iemetis ka es caur curl savacu ehr top listi,

http://paste.php.lv/...0f82d4?lang=php

 

EDIT

 

Atceries , lai darbinātu kurlu, tev vajag ieslegt php_ini.. extenshenu, pateiksu prieks ;) php_curl.dll/so

Edited by EdgarsA
Link to comment
Share on other sites

uj :) piedod

 

 

<?php

function read_header($ch, $string) {
global $cookiearr;
global $ch;
$length = strlen($string);
if(!strncmp($string, "Location:", 9)) {
$location = trim(substr($string, 9, -1));
}
if(!strncmp($string, "Set-Cookie:", 11)) {
$cookiestr = trim(substr($string, 11, -1));
$cookie = explode(';', $cookiestr);
$cookie = explode('=', $cookie[0]);
$cookiename = trim(array_shift($cookie));
if($cookiename) { 
	$cookiearr[$cookiename] = trim(implode('=', $cookie));
}
}
$cookie = "";
if(trim($string) == "") {
if(!empty($cookiearr)) foreach ($cookiearr as $key=>$value) {
	$cookie .= "$key=$value; ";
}
$cookie=str_replace(" ","",$cookie);
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
}
return $length;
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://php.lv");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'read_header'); 
$html = curl_exec($ch);
?>

 

krikuli - tavs cookiejar variants ir galigi garam, vins ir chakarigs daziem strada daziem ne, kautkadi chmodi jaskatas etc.. lieks chakars

Edited by EdgarsA
Link to comment
Share on other sites

Nu kāpēc par kūkijiem... man vajag sesijas vilkt līdzi... vai tas vispār ir iespējams?

 

luk es tev iedevu funkciju kura savac gan cukijus gan sesiju tak

ta ir hedera funkcija, kura savac savejerus vaitad ne ta ?

es nesmu gan sekojis lidzi vai tur sez abi divi, bet liekas ka butu jasez.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...