Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP how to fail a request

Tags:

php

Honestly, I don't know a lot about PHP but I think what I need to do is relatively simple.

I'm using ASIHTTPRequest http://allseeing-i.com/ASIHTTPRequest/ in an iOS app. I simply need to add code to my PHP script that will make the request fail, therefore calling the requestFailed delegate method of ASI. I would assume this is with an HTTP Response code but everything I've tried results int he request succeeding. I'm sure I'm doing something wrong but I don't really know PHP.

I've tried

trigger_error("error yo", E_USER_ERROR);
die;

As well as

header("HTTP/1.0 404 Not Found");
die;
like image 680
Brandon Schlenker Avatar asked Jul 11 '11 23:07

Brandon Schlenker


Video Answer


1 Answers

I ended up using this

header('HTTP/1.1 401 Unauthorized');

Turns out ASI doesn't handle most HTTP Response codes except authentication and moved.

like image 106
Brandon Schlenker Avatar answered Oct 30 '22 01:10

Brandon Schlenker