Guzzle HTTP Client - statusCode

1,464 views
Skip to first unread message

Bartłomiej Rosa

unread,
Jul 3, 2013, 8:18:27 PM7/3/13
to guz...@googlegroups.com

Hello guys.

I am getting some cURL data using Guzzle Framework.

Code

$client = new Client();
$request = $client->get($url);
$response = $request->send(); 
$status = $response->getStatusCode();
 

After X requests I am getting 403 forbidden error code, mostly more than 150.

Any solutions?

Bartłomiej Rosa

unread,
Jul 3, 2013, 8:52:09 PM7/3/13
to guz...@googlegroups.com
Was trying a bit workaround, but error still occurs. Any suggestions will be appreciated.
 
if ($response->isError()) {
            if($status == 403) {
                sleep(5);
                do {

                    $request = $client->get($url);
                    $response = $request->send();

                    $status = $response->getStatusCode();
                } while ($status != 403);
            }
        } else {
            return $response->getBody(/* $asString = */ true);
        }

Michael Dowling

unread,
Jul 3, 2013, 9:02:49 PM7/3/13
to guz...@googlegroups.com
403 is a permission issue, so you might need to add basic auth headers to some requests. Try turning on the debug request option to see what's being sent over the wire.

Thanks,
Michael
--
You received this message because you are subscribed to the Google Groups "Guzzle - PHP HTTP client and REST client framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to guzzle+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages