symfonyは自身の残りのクライアントを持っていませんが、あなたはすでに述べたようにバンドルのカップルがあります。この1は私のものを好まれる:
https://github.com/CircleOfNice/CiRestClientBundle
$restClient = $this->container->get('ci.restclient');
$restClient->get('http://www.someUrl.com');
$restClient->post('http://www.someUrl.com', 'somePayload');
$restClient->put('http://www.someUrl.com', 'somePayload');
$restClient->delete('http://www.someUrl.com');
$restClient->patch('http://www.someUrl.com', 'somePayload');
$restClient->head('http://www.someUrl.com');
$restClient->options('http://www.someUrl.com', 'somePayload');
$restClient->trace('http://www.someUrl.com');
$restClient->connect('http://www.someUrl.com');
あなたは
$response = $restclient->get($url);
経由でリクエストを送信し、symfonyのレスポンスオブジェクトを取得します。 そして、あなたはあなたのコードは次のようになり
$httpCode = $response-> getStatusCode();
を経由してステータスコードを取得することができます:私は知っている
$restClient = $this->container->get('ci.restclient');
if ($restClient->get('http://www.yourUrl.com')->getStatusCode !== 200) {
// no error
} else {
// error
}
どのような種類のリクエストですか?ちょうどHTTP GET? –
GETまたはPOSTは知っておくと良いでしょう;) – ElPiter