POST XML to URL with PHP and Handle Response

后端 未结 5 964
天命终不由人
天命终不由人 2020-12-11 11:16

I\'ve seen numerous methods of POSTing data with PHP over the years, but I\'m curious what the suggested method is, assuming there is one. Or perhaps there is a somewhat uns

5条回答
  •  情深已故
    2020-12-11 12:11

    I like Zend_Http_Client from Zend Framework.

    It basically works using stream_context_create() and stream_socket_client().

    Small example:

    $client = new Zend_Http_Client();
    $client->setUri('http://example.org');
    $client->setParameterPost('foo', 'bar')
    $response = $client->request('POST');
    
    $status = $response->getStatus();
    $body = $response->getBody();
    

提交回复
热议问题