Hello,

The script snapshot you've posted won't work with OAuth. It'll need to be 
rewritten for the interaction to work again. If I have time later today I'll 
modify the code and send you a replacement over.

Scott.

On 20 Sep 2010, at 10:27, Christoph Leuthold wrote:

> Hello There!
> 
> At the moment i am trying to get Chirrup (http://
> chirrup.angryamoeba.co.uk, a Twitter Comment System) to work. As the
> Chirrup Script hasn't been updated since 2008 it has not implemented
> the new Authentication method yet. I just tried to figure out how i
> could change the Skript to work again.
> 
> I have no clue how to reacht my goal, and maybe you can help me.
> 
> This is the actual code thats does all the Twitter API stuff right
> now, ho can i alter to code to use the new auth?
> 
> <?php
> 
>       require_once(dirname(__FILE__)."/../../config/chirrup_config.php");
>       require_once(dirname(__FILE__)."/twitter_cache.php");
> 
>       // The Twitter class provides an interface for making authenticated
> API calls
>       // to twitter via curl. Since Chirrup needs only a tiny subset of
> Twitter's
>       // API methods, although if you wish to extend it the
> makeAuthenticatedRequest
>       // contains pretty much all you need to do so.
> 
>       //
> 
>       class Twitter {
> 
>               // API calls
>               //
> --------------------------------------------------------------------------------
>               function getReplies($since_id=false) {
>                       // API documentation
>      //
>                       // Returns the 20 most recent replies (status updates 
> prefixed with
> @username posted by users who are friends with the user being replied
> to)
>                       // to the authenticating user.  Replies are only 
> available to the
> authenticating user; you can not request a list of replies to another
> user whether
>                       // public or protected.
>                       // URL: http://twitter.com/statuses/replies.format
>                       // Formats: xml, json, rss, atom
>                       // Parameters:
>                       // page.                Optional. Retrieves the 20 next 
> most recent replies.
> Ex: http://twitter.com/statuses/replies.xml?page=3
>                       // since.               Optional.  Narrows the returned 
> results to just those
> replies created after the specified HTTP-formatted date.
>                       //                              The same behavior is 
> available by setting an If-Modified-
> Since header in your HTTP request.  Ex:
> http://twitter.com/statuses/replies.xml?since=Tue%2C+27+Mar+2007+22%3A55%3A48+GMT
>                       // since_id.    Optional.  Returns only statuses with 
> an ID greater
> than (that is, more recent than) the specified ID.  Ex:
> http://twitter.com/statuses/replies.xml?since_id=12345
>                       $url = "http://twitter.com/statuses/replies.xml";;
>                       if($since_id) $url .= "?since_id=".$since_id;
>                       return $this->makeAuthenticatedRequest($url);
>               }
> 
>               function postStatus($username, $password, $status) {
>                               $url = 
> "http://twitter.com/statuses/update.xml?status=".urlencode(
> stripslashes( urldecode($status)      )       );
> 
>                   $curler = curl_init();
>                   curl_setopt($curler, CURLOPT_URL, $url);
>                   curl_setopt($curler, CURLOPT_VERBOSE, 1);
>                   curl_setopt($curler, CURLOPT_RETURNTRANSFER, 1);
>                   curl_setopt($curler, CURLOPT_USERPWD, 
> $username.":".$password);
>                   curl_setopt($curler, CURLOPT_POST, 1);
> 
>                   $result = curl_exec($curler);
>                   $result_headers = curl_getinfo($curler);
> 
>                   curl_close($curler);
> 
>                               // Return false by result code
>                               return ($result_headers['http_code'] == "200")? 
> true : false;
>               }
> 
>               // Generic requester
>               //
> --------------------------------------------------------------------------------
> 
>               function makeAuthenticatedRequest($url) {
>                       $curler = curl_init();
>                       curl_setopt($curler, CURLOPT_URL, $url);
>                       curl_setopt($curler, CURLOPT_CONNECTTIMEOUT, 2);
>                       curl_setopt($curler, CURLOPT_RETURNTRANSFER, 1);
>                       //curl_setopt($curler, CURLOPT_POST, 0);
>                       curl_setopt($curler, CURLOPT_USERPWD,
> TWITTER_USERNAME.":".TWITTER_PASSWORD);
>                       $result = curl_exec($curler);
>                       $result_headers = curl_getinfo($curler);
>                       curl_close($curler);
>                       // Key by response code to cope with "not modified" 
> responses which
> should
>                       // technically cause the request to return true. We 
> want to return
> false in that
>                       // instance to signify a general failure to fetch 
> anything new.
>                       if(!empty($result)) {
>                               return $result;
>                       } else {
>                               return false;
>                       }
>               }
> 
>       }
> 
> ?>
> 
> 
> Thanks for your help!
> Greetings Chris
> 
> 
> PS: Is there a good way to Post code here? Like [code][/code] ??
> 
> -- 
> Twitter developer documentation and resources: http://dev.twitter.com/doc
> API updates via Twitter: http://twitter.com/twitterapi
> Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
> Change your membership to this group: 
> http://groups.google.com/group/twitter-development-talk?hl=en


Scott Wilcox

t:      +44 (0) 7538 842418 
        +1 (646) 257 0580
e:      sc...@dor.ky
w:      http://dor.ky

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk?hl=en

Reply via email to