Tag Archives: http

Python SimpleHTTPServer with PHP

Questions: I used python -m SimpleHTTPServer, but the PHP files don’t execute instead they just been downloaded. I heard about WPHP in an old post. But I don’t know how to use it. How I can work with it ? Answers:

How to scrape a SSL or HTTPS URL

Questions: I have written a function to scrape a website using CURL but it returns nothing when called and can’t understand why. The output is empty <?php function scrape($url) { $headers = Array( “Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5”, “Cache-Control: max-age=0”, “Connection: keep-alive”, “Keep-Alive: 300”, “Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7”, “Accept-Language: en-us,en;q=0.5”, “Pragma: ” ); $config = Array( CURLOPT_RETURNTRANSFER => TRUE ,… Read More »

How to issue HTTP POST request?

Questions: curl -F ‘access_token=…’ \ -F ‘message=Hello, Arjun. I like this new API.’ \ https://graph.facebook.com/arjun/feed The documentation says I need to issue one to publish to the wall. Answers:

XMLHttpRequest to open PDF in browser

Questions: I want to do XMLHttpRequest and then open a PDF in the Browser by sending the filename by POST method. xmlhttp.open(“POST”,”pdf.php”,true); //CHANGE xmlhttp.setRequestHeader(“Content-type”,”application/x-www-form-urlencoded”); xmlhttp.send(“file=”+input); Is that possible or XMLHttpRequest is just for HTML? Answers:

Extract Scheme and Host from HTTP_REFERER

Questions: I have $_SERVER[‘HTTP_REFERER’] — pretend it is http://example.com/i/like/turtles.html. What would I need to do to get just the http://example.com part out of the string, and store it in its own variable? Answers:

HTTP request failed! HTTP/1.1 505 HTTP Version Not Supported error

Questions: I’m trying to use file_get_contents() to get the response from a server and this error was encountered. Could someone tell me what is the reason and how to fix it? The portion of the code is: $api = “http://smpp5.routesms.com:8080/bulksms/sendsms?username=$username&password=$password&source=$source&destination=$destin&dlr=$dlr&type=$type&message=$message”; $resp = file_get_contents($api); The server responded correctly while I pasted the url in the browser.… Read More »

can use httpClient in Android Studio?

Questions: i use httpClient to send data to php file like this php <?php echo $_POST[‘My_Data’]; ?> and i add <uses-permission android:name=”android.permission.INTERNET” /> to AndroidManifest.xml for connect internet. this is my main Activity SendActivity.java public class SendActivity extends ActionBarActivity { String myJSON; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_send); SendData(); } public void SendData(){… Read More »

Need response body of HTTP 500 with file_get_contents (PHP)

Questions: Using file_get_contents as part of custom SOAP implementation to apply SOAP calls (ALL libraries that we tried would not do SSL + certificate based authentication with SOAP 1.2 correctly). However difficult and barely-documented API often returns 500. There are error details in response body, but file_get_contents doesn’t appear to allow access to it. fopen… Read More »