Posts

Showing posts from March, 2018

Checking strpos - PHP's idea of BPD

Suppose you need to make sure that a certain path does not contain a certain string. 1. strpos($CurrentPath,'node/12345/') < 0 Will not fire because the return value is FALSE. 2. strpos($CurrentPath,'node/12345/') == FALSE Will fire even when the path starts with the string because a return value of 0 evaluates to FALSE. 3. !(strpos($CurrentPath,'node/12345/') > -1) Finally!

CURL not working — check for HTTPS before emulating browser requests

CURL requests to certain URLs that were working fine seemed to stop working overnight. The requests seemed to go through fine on the browser. After monitoring network requests and getting CURL to emulate browser requests using user agent headers, it turned out that the said server had simply stopped servicing HTTP requests. Browser requests were being redirected to HTTPS. CURL requests were not. All that needed to be done was convert the HTTP requests to HTTPS.