I'm using PHP curl post xml command to Solr,Is it the only way to post data?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

I'm using PHP curl post xml command to Solr,Is it the only way to post data?

Kijiji Xu, Ping
What about fsockopen, Or any other simple method?

 

Thanks

 

--

Regards

Xp from china

Reply | Threaded
Open this post in threaded view
|

Re: I'm using PHP curl post xml command to Solr,Is it the only way to post data?

mgkimsal
Using PHP5 (5.1 or higher I think)
http://us.php.net/manual/en/function.http-post-fields.php
is available.

From the example on that page:

$fields = array(
    'name' => 'mike',
    'pass' => 'passwordt'
);
$response = http_post_fields("http://www.example.com/", $fields);


Looks pretty simple, but I haven't tried it yet.

On 6/25/07, Kijiji Xu, Ping <[hidden email]> wrote:

>
> What about fsockopen, Or any other simple method?
>
>
>
> Thanks
>
>
>
> --
>
> Regards
>
> Xp from china
>
>


--
Michael Kimsal
http://webdevradio.com
Reply | Threaded
Open this post in threaded view
|

RE: I'm using PHP curl post xml command to Solr,Is it the only way to post data?

Kijiji Xu, Ping
In our product environment, there haven't curl and pecl lib,so...
If the fsockopen could solve post xml data,I would like to use it.And I tried it, but I failed.

-----Original Message-----
From: Michael Kimsal [mailto:[hidden email]]
Sent: 2007年6月25日 20:16
To: [hidden email]
Subject: Re: I'm using PHP curl post xml command to Solr,Is it the only way to post data?

Using PHP5 (5.1 or higher I think)
http://us.php.net/manual/en/function.http-post-fields.php
is available.

From the example on that page:

$fields = array(
    'name' => 'mike',
    'pass' => 'passwordt'
);
$response = http_post_fields("http://www.example.com/", $fields);


Looks pretty simple, but I haven't tried it yet.

On 6/25/07, Kijiji Xu, Ping <[hidden email]> wrote:

>
> What about fsockopen, Or any other simple method?
>
>
>
> Thanks
>
>
>
> --
>
> Regards
>
> Xp from china
>
>


--
Michael Kimsal
http://webdevradio.com
Reply | Threaded
Open this post in threaded view
|

Re: I'm using PHP curl post xml command to Solr,Is it the only way to post data?

Tristan Vittorio
Rather than re-inventing the wheel with fsockopen, why don't you use an
existing HTTP client implementation written in PHP:

http://pear.php.net/package/HTTP_Client
http://framework.zend.com/manual/en/zend.http.html
http://scripts.incutio.com/httpclient/
http://www.phpclasses.org/browse/package/576.html

They should all be able to perform the HTTP POST requests that you require
and will be a lot easier to use that writing raw HTTP protocol through a
socket!

regards,
Tristan



On 6/25/07, Kijiji Xu, Ping <[hidden email]> wrote:

>
> In our product environment, there haven't curl and pecl lib,so...
> If the fsockopen could solve post xml data,I would like to use it.And I
> tried it, but I failed.
>
> -----Original Message-----
> From: Michael Kimsal [mailto:[hidden email]]
> Sent: 2007年6月25日 20:16
> To: [hidden email]
> Subject: Re: I'm using PHP curl post xml command to Solr,Is it the only
> way to post data?
>
> Using PHP5 (5.1 or higher I think)
> http://us.php.net/manual/en/function.http-post-fields.php
> is available.
>
> From the example on that page:
>
> $fields = array(
>     'name' => 'mike',
>     'pass' => 'passwordt'
> );
> $response = http_post_fields("http://www.example.com/", $fields);
>
>
> Looks pretty simple, but I haven't tried it yet.
>
> On 6/25/07, Kijiji Xu, Ping <[hidden email]> wrote:
> >
> > What about fsockopen, Or any other simple method?
> >
> >
> >
> > Thanks
> >
> >
> >
> > --
> >
> > Regards
> >
> > Xp from china
> >
> >
>
>
> --
> Michael Kimsal
> http://webdevradio.com
>
Reply | Threaded
Open this post in threaded view
|

RE: I'm using PHP curl post xml command to Solr,Is it the only way to post data?

Kijiji Xu, Ping
I had solved this problem,below is my POST code,I used HTTP_Request of PEAR,it’s so simple.thank you all very much .FYI;


private function doPost($url,$postData){
         $req = &new HTTP_Request($url,array(
        'method' => HTTP_REQUEST_METHOD_POST,
        'http' => HTTP_REQUEST_HTTP_VER_1_1));
         $req->addHeader('Content-Type','text/xml; charset=utf-8');
         $req->addHeader('Content-Length',strlen($postData));
         $req->addRawPostData($postData,true);
         $req->sendRequest();
         $response1 = $req->getResponseBody();
         echo $response1."\n";
         return $response1;
}


-----Original Message-----
From: Tristan Vittorio [mailto:[hidden email]]
Sent: 2007年6月25日 21:36
To: [hidden email]
Subject: Re: I'm using PHP curl post xml command to Solr,Is it the only way to post data?

Rather than re-inventing the wheel with fsockopen, why don't you use an
existing HTTP client implementation written in PHP:

http://pear.php.net/package/HTTP_Client
http://framework.zend.com/manual/en/zend.http.html
http://scripts.incutio.com/httpclient/
http://www.phpclasses.org/browse/package/576.html

They should all be able to perform the HTTP POST requests that you require
and will be a lot easier to use that writing raw HTTP protocol through a
socket!

regards,
Tristan



On 6/25/07, Kijiji Xu, Ping <[hidden email]> wrote:

>
> In our product environment, there haven't curl and pecl lib,so...
> If the fsockopen could solve post xml data,I would like to use it.And I
> tried it, but I failed.
>
> -----Original Message-----
> From: Michael Kimsal [mailto:[hidden email]]
> Sent: 2007年6月25日 20:16
> To: [hidden email]
> Subject: Re: I'm using PHP curl post xml command to Solr,Is it the only
> way to post data?
>
> Using PHP5 (5.1 or higher I think)
> http://us.php.net/manual/en/function.http-post-fields.php
> is available.
>
> From the example on that page:
>
> $fields = array(
>     'name' => 'mike',
>     'pass' => 'passwordt'
> );
> $response = http_post_fields("http://www.example.com/", $fields);
>
>
> Looks pretty simple, but I haven't tried it yet.
>
> On 6/25/07, Kijiji Xu, Ping <[hidden email]> wrote:
> >
> > What about fsockopen, Or any other simple method?
> >
> >
> >
> > Thanks
> >
> >
> >
> > --
> >
> > Regards
> >
> > Xp from china
> >
> >
>
>
> --
> Michael Kimsal
> http://webdevradio.com
>
Reply | Threaded
Open this post in threaded view
|

Re: I'm using PHP curl post xml command to Solr,Is it the only way to post data?

James liu-2
how about its performance?

2007/6/26, Kijiji Xu, Ping <[hidden email]>:

>
> I had solved this problem,below is my POST code,I used HTTP_Request of
> PEAR,it's so simple.thank you all very much .FYI;
>
>
> private function doPost($url,$postData){
>          $req = &new HTTP_Request($url,array(
>         'method' => HTTP_REQUEST_METHOD_POST,
>         'http' => HTTP_REQUEST_HTTP_VER_1_1));
>          $req->addHeader('Content-Type','text/xml; charset=utf-8');
>          $req->addHeader('Content-Length',strlen($postData));
>          $req->addRawPostData($postData,true);
>          $req->sendRequest();
>          $response1 = $req->getResponseBody();
>          echo $response1."\n";
>          return $response1;
> }
>
>
> -----Original Message-----
> From: Tristan Vittorio [mailto:[hidden email]]
> Sent: 2007年6月25日 21:36
> To: [hidden email]
> Subject: Re: I'm using PHP curl post xml command to Solr,Is it the only
> way to post data?
>
> Rather than re-inventing the wheel with fsockopen, why don't you use an
> existing HTTP client implementation written in PHP:
>
> http://pear.php.net/package/HTTP_Client
> http://framework.zend.com/manual/en/zend.http.html
> http://scripts.incutio.com/httpclient/
> http://www.phpclasses.org/browse/package/576.html
>
> They should all be able to perform the HTTP POST requests that you require
> and will be a lot easier to use that writing raw HTTP protocol through a
> socket!
>
> regards,
> Tristan
>
>
>
> On 6/25/07, Kijiji Xu, Ping <[hidden email]> wrote:
> >
> > In our product environment, there haven't curl and pecl lib,so...
> > If the fsockopen could solve post xml data,I would like to use it.And I
> > tried it, but I failed.
> >
> > -----Original Message-----
> > From: Michael Kimsal [mailto:[hidden email]]
> > Sent: 2007年6月25日 20:16
> > To: [hidden email]
> > Subject: Re: I'm using PHP curl post xml command to Solr,Is it the only
> > way to post data?
> >
> > Using PHP5 (5.1 or higher I think)
> > http://us.php.net/manual/en/function.http-post-fields.php
> > is available.
> >
> > From the example on that page:
> >
> > $fields = array(
> >     'name' => 'mike',
> >     'pass' => 'passwordt'
> > );
> > $response = http_post_fields("http://www.example.com/", $fields);
> >
> >
> > Looks pretty simple, but I haven't tried it yet.
> >
> > On 6/25/07, Kijiji Xu, Ping <[hidden email]> wrote:
> > >
> > > What about fsockopen, Or any other simple method?
> > >
> > >
> > >
> > > Thanks
> > >
> > >
> > >
> > > --
> > >
> > > Regards
> > >
> > > Xp from china
> > >
> > >
> >
> >
> > --
> > Michael Kimsal
> > http://webdevradio.com
> >
>



--
regards
jl
Reply | Threaded
Open this post in threaded view
|

RE: I'm using PHP curl post xml command to Solr,Is it the only way to post data?

Kijiji Xu, Ping
Ya,it cost 20-30ms per every update 1 doc operation(add,delete command) ,but not commit. So, I think it'a all right

-----Original Message-----
From: James liu [mailto:[hidden email]]
Sent: 2007年6月27日 9:39
To: [hidden email]
Subject: Re: I'm using PHP curl post xml command to Solr,Is it the only way to post data?

how about its performance?

2007/6/26, Kijiji Xu, Ping <[hidden email]>:

>
> I had solved this problem,below is my POST code,I used HTTP_Request of
> PEAR,it's so simple.thank you all very much .FYI;
>
>
> private function doPost($url,$postData){
>          $req = &new HTTP_Request($url,array(
>         'method' => HTTP_REQUEST_METHOD_POST,
>         'http' => HTTP_REQUEST_HTTP_VER_1_1));
>          $req->addHeader('Content-Type','text/xml; charset=utf-8');
>          $req->addHeader('Content-Length',strlen($postData));
>          $req->addRawPostData($postData,true);
>          $req->sendRequest();
>          $response1 = $req->getResponseBody();
>          echo $response1."\n";
>          return $response1;
> }
>
>
> -----Original Message-----
> From: Tristan Vittorio [mailto:[hidden email]]
> Sent: 2007年6月25日 21:36
> To: [hidden email]
> Subject: Re: I'm using PHP curl post xml command to Solr,Is it the only
> way to post data?
>
> Rather than re-inventing the wheel with fsockopen, why don't you use an
> existing HTTP client implementation written in PHP:
>
> http://pear.php.net/package/HTTP_Client
> http://framework.zend.com/manual/en/zend.http.html
> http://scripts.incutio.com/httpclient/
> http://www.phpclasses.org/browse/package/576.html
>
> They should all be able to perform the HTTP POST requests that you require
> and will be a lot easier to use that writing raw HTTP protocol through a
> socket!
>
> regards,
> Tristan
>
>
>
> On 6/25/07, Kijiji Xu, Ping <[hidden email]> wrote:
> >
> > In our product environment, there haven't curl and pecl lib,so...
> > If the fsockopen could solve post xml data,I would like to use it.And I
> > tried it, but I failed.
> >
> > -----Original Message-----
> > From: Michael Kimsal [mailto:[hidden email]]
> > Sent: 2007年6月25日 20:16
> > To: [hidden email]
> > Subject: Re: I'm using PHP curl post xml command to Solr,Is it the only
> > way to post data?
> >
> > Using PHP5 (5.1 or higher I think)
> > http://us.php.net/manual/en/function.http-post-fields.php
> > is available.
> >
> > From the example on that page:
> >
> > $fields = array(
> >     'name' => 'mike',
> >     'pass' => 'passwordt'
> > );
> > $response = http_post_fields("http://www.example.com/", $fields);
> >
> >
> > Looks pretty simple, but I haven't tried it yet.
> >
> > On 6/25/07, Kijiji Xu, Ping <[hidden email]> wrote:
> > >
> > > What about fsockopen, Or any other simple method?
> > >
> > >
> > >
> > > Thanks
> > >
> > >
> > >
> > > --
> > >
> > > Regards
> > >
> > > Xp from china
> > >
> > >
> >
> >
> > --
> > Michael Kimsal
> > http://webdevradio.com
> >
>



--
regards
jl