Just a shot in the dark, but could it be caused by this?:

http://groups.google.com/group/twitter-development-talk/browse_thread/thread/f7cd82f2c43a77d0/464d0df7446d43e7

It sounds like exactly the sort of thing that could cause an app to suddenly
stop working.  I see that your new code posted above contained a referer,
but what about the code that was failing?  How about putting in a User-Agent
too, for good measure.

Regards,

Alan Evans

On Fri, Jun 19, 2009 at 2:50 PM, markanson <mark.an...@gmail.com> wrote:

>
> Marco it was all working fine for a month or more
>
> then today it stopped working
>
> My new code that I got from somewhere seems ok but I don't feel really
> confident about this
>
> I am using this
>
>
>
> function file_post_contents($url,$headers=false) {
>    $url = parse_url($url);
>
>    if (!isset($url['port'])) {
>      if ($url['scheme'] == 'http') { $url['port']=80; }
>      elseif ($url['scheme'] == 'https') { $url['port']=443; }
>    }
>    $url['query']=isset($url['query'])?$url['query']:'';
>
>    $url['protocol']=$url['scheme'].'://';
>    $eol="\r\n";
>
>    $headers =  "POST ".$url['protocol'].$url['host'].$url['path']."
> HTTP/1.0".$eol.
>                "Host: ".$url['host'].$eol.
>                "Referer: ".$url['protocol'].$url['host'].$url['path'].
> $eol.
>                "Content-Type: application/x-www-form-urlencoded".
> $eol.
>                "Content-Length: ".strlen($url['query']).$eol.
>                $eol.$url['query'];
>    $fp = fsockopen($url['host'], $url['port'], $errno, $errstr, 30);
>    if($fp) {
>      fputs($fp, $headers);
>      $result = '';
>      while(!feof($fp)) { $result .= fgets($fp, 128); }
>      fclose($fp);
>      if (!$headers) {
>        //removes headers
>        $pattern="/^.*\r\n\r\n/s";
>        $result=preg_replace($pattern,'',$result);
>      }
>      return $result;
>    }
> }
>
>

Reply via email to