Hi. Thanks. Well I tried it from a shared server. I got some success but then I added
httpRequest('twitter.com'); echo "<p>Response:<br /><hr /><pre>$response</pre><hr /></p>n"; httpRequest('twitter.com', '/statuses/update.xml?status=I am testing the Twitter API', 'POST'); echo "<p>Response:<br /><hr /><pre>$response</pre><hr /></p>n"; httpRequest('twitter.com', '/statuses/update.xml?status=Test+Test +1+2+3!', 'POST'); echo "<p>Response:<br /><hr /><pre>$response</pre><hr /></p>n"; just underneath the line: //<!-- Replace the following code for later examples from the article --> but it does not seem to write to my account. Also, the webpage takes a long time to load (about 90 secs) and then shows Contacting Twitter... n Response: n Response: n Response: n with three sets of two horizontal lines. Any idea why it is not writing to my account? Thanks! On Mar 30, 12:11 pm, Ed Finkler <funkat...@gmail.com> wrote: > Okay, first off, the "Fatal error" is happening because PHP on your > install is set-up to time-out scripts after 60 seconds (this is to > avoid runaway processes on the server). > > I'm not sure exactly why your socket connection is timing out. One > possibility is that a local firewall is blocking outgoing connections > until you explicitly allow them. > > I'd recommend installing a Windows binary of curl for testing on the > command line, and also grabbing a copy of the Charles debugging proxy > to see what's actually being sent and received (if anything!). > > -- > Ed Finklerhttp://funkatron.com > Twitter:@funkatron > AIM: funka7ron > ICQ: 3922133 > XMPP:funkat...@gmail.com > > On Mar 29, 10:37 pm, Bill <william...@gmail.com> wrote: > > > Hi, I tried to access the twitter API with the following code but I > > get the error: > > Contacting Twitter... > > n > > Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp > > \htdocs\twitter.php on line 26 > > > I am running this from an apache server on my home computer > > at:http://127.0.0.1/twitter.php > > > I have not applied for any special account with twitter, just my > > regular twitter id and password were entered. Can anyone tell me why > > this is not working? > > Thanks! > > > <?php > > $twitter_username = 'xxxx'; > > $twitter_password = 'xxxx'; > > > $errno = 0; > > $errstr = ''; > > $response = ''; > > > function httpRequest($host, $path = '/', $method = 'GET') { > > > global $errno, $errstr, $response; > > global $twitter_username, $twitter_password; > > > $header = "$method $path HTTP/1.1rn"; > > $header .= "Host: $hostrn"; > > $header .= "Accept-Encoding: nonern"; > > $header .= "Authorization: Basic " . base64_encode > > ("{$twitter_username}:{$twitter_password}") . "rn"; > > $header .= "Connection: Closernrn"; > > > $sock = fsockopen($host, 80, $errno, $errstr, 30); > > if (!$sock) { > > die("<p><strong>fsockopen() error:</strong><br />$errstr ($errno) > > </p>"); > > } else { > > fwrite($sock, $header); > > while (!feof($sock)) { > > $response .= fgets($sock, 128); > > } > > fclose($sock); > > > $response = trim(str_replace(array('<', '>'), array('<', > > '>'), $response)); > > return true; > > } > > > } > > > echo "<p>Contacting Twitter...</p>n"; > > > //<!-- Replace the following code for later examples from the article > > --> > > httpRequest('twitter.com'); > > echo "<p>Response:<br /><hr /><pre>$response</pre><hr /></p>n"; > > > ?>