It is quite weird seeing familiar streets with totally unfamiliar skyscrapers and bridges in the background. Zombies are quite normal however.
Niall Barr
Posts
-
World War Z -
War on science?The geologists said an earthquake was unlikely, but possible. They did not advise people to stay indoors. The majority of the people who gave that advice were not put on trial.
-
hi evry body(i need expord doc with html)You should look into headless openoffice
-
free cloud hosting for testing purposeYes, EC2 does support .NET, but not on the free tier. The cost can be very low if you only run the server for occasional tests, but is similar to a conventional hosted VM if you need it running all the time.
-
determine page titleThe usual approach would be to look for the first heading tag using preg_match. You could also look for the tag. <meta> elements are usually only useful if you're looking at pages where you know that metadata has been added, and know the metadata profile that has been followed.</x-turndown>
-
signature_invalid in Google APIYou need to be very careful while doing this sort of thing - any little errors are going to break it, and can be hard to track down. A few I've spotted are:
- You have the 'scope' parameter out of sequence when building the data to sign. Data must be ordered alphabetically by key for the oauth signature to be correct.
- You use "GET" as a parameter for calculateBaseString although you're using POST
- You miss out the & delimiter when adding the oauth_signature
- You call curl_setopt($ch, CURLOPT_POSTFIELDS twice, overwriting the OAuth signed data with a single parameter.
It's very possible there are other errors I've not spotted. Niall
-
Creating file headers in php.This bit of code shows you how to write an integer to an ASCII text file, then (as a four byte long) to a binary file. The key thing is that pack is used to convert the integer into a character array equivalent to its binary representation before writing it. The default behavior of PHP when writing variables to a file is to convert them to strings.
-
Creating file headers in php.If you really need to work with binary files in PHP you need to use the pack and unpack functions, along with the C like file functions (fopen, fseek, fread etc.), however if you need to work with binary files you probably really need to consider whether PHP is an appropriate language for your application. Niall
-
uploading file via postIt occured to me that it's likely that the site you're posting to expects an attached file rather than the file content in a post field called file... If that's the case, then this code should work.
-
uploading file via postI think the only issue was the amount of memory available to PHP on my dev box. I tried with a file that was too big for it. Are you able to get the other post data transferred if you comment out the file_get_contents line? Niall
-
uploading file via postNo - that works on my system, as long as the CSV file isn't too big. (OK with 150k, not with 30M) This is the version of your code I tried out.
<?php
function datapost($URLServer,$postdata)
{$agent = "Mozilla/5.0"; $cURL\_Session = curl\_init(); curl\_setopt($cURL\_Session, CURLOPT\_URL,$URLServer); curl\_setopt($cURL\_Session, CURLOPT\_USERAGENT, $agent); curl\_setopt($cURL\_Session, CURLOPT\_HTTPGET, FALSE); //curl\_setopt($cURL\_Session, CURLOPT\_POST, 1); curl\_setopt($cURL\_Session, CURLOPT\_POSTFIELDS,$postdata); curl\_setopt($cURL\_Session, CURLOPT\_RETURNTRANSFER, 1); curl\_setopt($cURL\_Session, CURLOPT\_FOLLOWLOCATION, 1); $result = curl\_exec($cURL\_Session); return $result;
}
$postdata = array(); $postdata\['Id'\] = '12340'; $postdata\['profileName'\] = 'tsunami'; $postdata\['file'\] = file\_get\_contents('http://localhost/tmp/test.csv'); $postdata\['submit'\] = urlencode('submit'); $source= datapost("http://localhost/tmp/posthere.php",$postdata); echo $source;
?>
My test posthere.php is
-
uploading file via postHi, You need to set CURLOPT_HTTPGET to false explicitly - the PHP documentation doesn't make this clear. curl_setopt($cURL_Session, CURLOPT_HTTPGET, FALSE); Niall
-
Old calculators...I think I bought my HP 11 in 1987 - currently on it's second set of batteries I think.
-
Exporting HTML file to PDF formatYou could look into using OpenOffice.org headless. There are also some PHP libraries for writing PDF - http://www.fpdf.org/[^] is one that doesn't need any extensions installed.
-
imap_search problemI'm surprised that works at all - POP3 and IMAP are quite different. I don't think a POP3 server keeps any information on which messages are read however, so unless you have IMAP mailboxes configured on the server you will just get a list of all messages.
-
imap_search problemI'm afraid I don't know much about IMAP servers, so can't help there. Niall
-
imap_search problemYour code looks OK - could it be something strange about the server configuration? I just tried this code to get IMAP unread numbers from our exchange server and it worked fine.
<?php
$himap = imap_open ('{some.server.ac.uk:143}INBOX', 'username', 'password');$result = imap_search ($himap, 'UNSEEN');
if(is_array($result))
{
foreach ($result as $value)
{
echo "Unseen message number $value<br/>";
}
}
else
echo 'No unseen messages';
?> -
Friday's CCClistless A synonym for languid a boat that isn't listing would be vertical register = list, so without a register = listless
-
Programming Question: C++ Builder StringMany years ago I ported an app from Turbo C++ to VC++ - one quirk of Turbo was that it had a class that encapsulated Pascal style strings where the first character of the structure is the string length, so the actual string starts at offset 1 (and is limited to 255 characters).
-
Friday's easy CCCThank you