[twitter-dev] Re: whitelist site -- horror story

2009-06-20 Thread Shannon Whitley

I was thinking the same thing about the referrer.  I rushed over to
check on my apps after reading this thread.  I know this has been
broached before, but it sure would be nice to have a beta site for the
devs to test against before changes go live.

On Jun 19, 7:04 am, Doug Williams d...@twitter.com wrote:
 Can you include the specific request you are making?

 Thanks,
 Doug



 On Fri, Jun 19, 2009 at 6:35 AM, Alan Evans alanev...@gmail.com wrote:
  Just a shot in the dark, but could it be caused by this?:

 http://groups.google.com/group/twitter-development-talk/browse_thread...

  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;
     }
  }- Hide quoted text -

 - Show quoted text -


[twitter-dev] Re: whitelist site -- horror story

2009-06-19 Thread markanson

I have resolved this problem by changing from GET to POST requests. 14
hours work.

I am totally confused why the Get requests that were working for a
month no longer work

At least my application is working using POST... But I am worried
about the reliability of the code I've written

Not a good feeling

mark


[twitter-dev] Re: whitelist site -- horror story

2009-06-19 Thread Alan Evans
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;
}
 }




[twitter-dev] Re: whitelist site -- horror story

2009-06-19 Thread Doug Williams
Can you include the specific request you are making?

Thanks,
Doug



On Fri, Jun 19, 2009 at 6:35 AM, Alan Evans alanev...@gmail.com wrote:

 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;
}
 }