Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

javascript - What is the best way in PHP or JS to expand shortened URLs like Bitly, Tinyurl to find the original URL? -


i using twitter , facewbook api pull posts potentially contain shortened urls using bit.ly or tinyurl services. need real-time expansion original url pull content url app.

you can use curl expand short url.

try this:

    function traceurl($url, $hops = 0)     {         if ($hops == max_url_hops)         {             throw new exception('too_many_hops');         }          $ch = curl_init($url);         curl_setopt($ch, curlopt_header, 1);         curl_setopt($ch, curlopt_nobody, 1);         curl_setopt($ch, curlopt_returntransfer, 1);         curl_setopt($ch, curlopt_ssl_verifypeer, 0);         $r = curl_exec($ch);          if (preg_match('/location: (?p<url>.*)/i', $r, $match))         {             return traceurl($match['url'], $hops + 1);         }          return rtrim($url);     } 

you can use function traceurl('http://bit.ly/example'). function recursive in sense find short urls shortened (if ever happens). make sure set max_url_hops constant. use define('max_url_hops', 5);.

  • christian

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -