• 24-11-2010, 13:28:38
    #1
    Gmn
    Kimlik doğrulama veya yönetimden onay bekliyor.
    Merhaba arkadaşlar
    Elimde şu şekilde bi kod bulunuyor
    <?php
    $username = "TwitterUsername"; // Your twitter username.
    $prefix = ""; // Prefix - some text you want displayed before your latest tweet.
    $suffix = ""; // Suffix - some text you want display after your latest tweet.
    $feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1";
    
    function parse_feed($feed) {
    $stepOne = explode("<content type=\"html\">", $feed);
    $stepTwo = explode("</content>", $stepOne[1]);
    $tweet = $stepTwo[0];
    $tweet = str_replace("&lt;", "<", $tweet);
    $tweet = str_replace("&gt;", ">", $tweet);
    return $tweet;
    }
    
    $twitterFeed = file_get_contents($feed);
    echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);
    ?>
    kod twitterda yaptığım son tweetimi sitemde gösteriyor fakat şöyle bir sorunum var,
    tweet içinde yapan kişinin username linki şu şekilde olduğu için gereken sayfaya gidemiyor
    http://www.siteadi.com/deneme/"http://twitter.com/pnouma"

    kod içinde bazı değişiklikler denedim fakat çözümü bulamadım,yardımcı olurmusunuz.
  • 24-11-2010, 20:12:16
    #2
    Merak ediyordum bunu dediğin sorunu da çözdük mü güzel bir kod olur biraz kafa yoralım.
  • 24-11-2010, 22:59:05
    #3
    Buyur hocam fonksiyon yazdım.
    <?php
        function twitfeed($username){
            $twitfeedsource = file_get_contents("http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1");
            preg_match("/<content type=\"html\">(.*?)<\/content>/",$twitfeedsource,$feedcontent);
            return htmlspecialchars_decode($feedcontent[1]);
        }
        echo twitfeed('wordpress');
    ?>
  • 24-11-2010, 23:40:55
    #4
    mrtoxic adlı üyeden alıntı: mesajı görüntüle
    Buyur hocam fonksiyon yazdım.
    <?php
        function twitfeed($username){
            $twitfeedsource = file_get_contents("http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1");
            preg_match("/<content type=\"html\">(.*?)<\/content>/",$twitfeedsource,$feedcontent);
            return htmlspecialchars_decode($feedcontent[1]);
        }
        echo twitfeed('wordpress');
    ?>
    tam olarak nasıl bir yol izlememiz gerekiyor bu fonksiyonla
    biraz daha yardımcı olurmusun
  • 24-11-2010, 23:51:29
    #5
    <?php
        /*
        * $username son tweetsini almak istediğiniz kullanıcı adını.
        * $before aldığınız tweetten önce gelmesini istediğiniz kod.
        * $after aldığınız tweetten sonra gelmesini istediğiniz kod. 
        */
        function twitfeed($username,$before='',$after=''){
            $twitfeedsource = file_get_contents("http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1");
            preg_match("/<content type=\"html\">(.*?)<\/content>/",$twitfeedsource,$feedcontent);
            return $before.htmlspecialchars_decode($feedcontent[1]).$after;
        }
        echo twitfeed('wordpress','Twitterdan alınan içerik öncesi<br />','<br />Alınan içerik sonrası');
    ?>
  • 25-11-2010, 00:17:52
    #6
    mrtoxic adlı üyeden alıntı: mesajı görüntüle
    <?php
        /*
        * $username son tweetsini almak istediğiniz kullanıcı adını.
        * $before aldığınız tweetten önce gelmesini istediğiniz kod.
        * $after aldığınız tweetten sonra gelmesini istediğiniz kod. 
        */
        function twitfeed($username,$before='',$after=''){
            $twitfeedsource = file_get_contents("http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1");
            preg_match("/<content type=\"html\">(.*?)<\/content>/",$twitfeedsource,$feedcontent);
            return $before.htmlspecialchars_decode($feedcontent[1]).$after;
        }
        echo twitfeed('wordpress','Twitterdan alınan içerik öncesi<br />','<br />Alınan içerik sonrası');
    ?>
    Bu kod sayesinde son tweet'imi gösteriyorum teşekkürler fakat
    benim sorunum şu phpdende çok anlamadığım için eksik bişeylerde yapıyosam kusura bakma ama benim verdiğim kodda
    egemenozbeyli : son tweet'im şeklinde gözüküyor ve
    egemenozbeyli link almış şekilde tıkladığımda benim adresime gidiyor fakat benim verdiğim kodda link sorunu olduğundan bunu çözmek istiyorum bana şunu tam olarak anlatırmısın benim ilk verdiğim kodda link sorununu çözmek için tam olarak ne yapmam gerekiyor acaba
  • 25-11-2010, 03:18:01
    #7
    htmlspecialchars_decode bunu yazdım, sen ise sadece < ve > karakterlerini düzeltmişsin.
  • 25-11-2010, 20:20:40
    #8
    Gmn kodu araştırdım ve buldum.

    $twitterid = "naimtufekci";
    //  Burayı Değiştirmen yeterli
    Demo : http://naimtufekci.com/scr/latest-twitter/
    Download : http://naimtufekci.com/scr/latest-twitter/indir.zip

    index.php
    <?php
    $twitterid = "naimtufekci";
    require_once('latesttweet.php');
    ?>
    latesttweet.php

    <?php
    // naimtufekci.com/scr/latest-twitter
    $username = $twitterid;
    $prefix = "<p>";
    $feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=2";
    function parse_feed($feed) {
        $stepOne = explode("<content type=\"html\">", $feed);
        $stepTwo = explode("</content>", $stepOne[1]);
        $tweet = $stepTwo[0];
        $tweet = str_replace("&lt;", "<", $tweet);
        $tweet = str_replace("&gt;", ">", $tweet);
        $tweet = str_replace("&quot;", "\"", $tweet);
        $tweet = str_replace("&amp;apos;", "'", $tweet);
        return $tweet;
    }
    $twitterFeed = file_get_contents($feed);
    echo $prefix.parse_feed($twitterFeed).$suffix;
    ?>
    ve bu arada twitter takipçi sayısını da şu kodla çekebilirsin.

    <?php
    function get_data($url) {
       $ch = curl_init();
       curl_setopt($ch, CURLOPT_URL, $url);
       curl_setopt($ch, CURLOPT_FAILONERROR, 1);
       curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
       curl_setopt($ch, CURLOPT_PORT, 80);
       curl_setopt($ch, CURLOPT_TIMEOUT, 30);
       curl_setopt($ch, CURLOPT_HEADER, false);
       curl_setopt($ch, CURLOPT_REFERER, $referer);
       //curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
       $document = curl_exec($ch);
       curl_close($ch);
       return $document;
    }
    $urlpage_data = get_data("http://www.twitter.com/naimtufekci");
    preg_match_all('#<span id="follower_count" class="stats_count numeric">(.*?)</span>#is', $urlpage_data, $urlmatches);
    echo "Tam tamına ". $urlmatches[1][0] ."takipçiniz var.";
    ?>
    Herhangi bir sorun olursa naim@naimtufekci.com mailinden ulaşabilirsin.
  • 28-11-2010, 14:24:09
    #9
    unarmedsoldier adlı üyeden alıntı: mesajı görüntüle
    Gmn kodu araştırdım ve buldum.

    $twitterid = "naimtufekci";
    //  Burayı Değiştirmen yeterli
    Demo : http://naimtufekci.com/scr/latest-twitter/
    Download : http://naimtufekci.com/scr/latest-twitter/indir.zip

    index.php
    <?php
    $twitterid = "naimtufekci";
    require_once('latesttweet.php');
    ?>
    latesttweet.php

    <?php
    // naimtufekci.com/scr/latest-twitter
    $username = $twitterid;
    $prefix = "<p>";
    $feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=2";
    function parse_feed($feed) {
        $stepOne = explode("<content type=\"html\">", $feed);
        $stepTwo = explode("</content>", $stepOne[1]);
        $tweet = $stepTwo[0];
        $tweet = str_replace("&lt;", "<", $tweet);
        $tweet = str_replace("&gt;", ">", $tweet);
        $tweet = str_replace("&quot;", "\"", $tweet);
        $tweet = str_replace("&amp;apos;", "'", $tweet);
        return $tweet;
    }
    $twitterFeed = file_get_contents($feed);
    echo $prefix.parse_feed($twitterFeed).$suffix;
    ?>
    ve bu arada twitter takipçi sayısını da şu kodla çekebilirsin.

    <?php
    function get_data($url) {
       $ch = curl_init();
       curl_setopt($ch, CURLOPT_URL, $url);
       curl_setopt($ch, CURLOPT_FAILONERROR, 1);
       curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
       curl_setopt($ch, CURLOPT_PORT, 80);
       curl_setopt($ch, CURLOPT_TIMEOUT, 30);
       curl_setopt($ch, CURLOPT_HEADER, false);
       curl_setopt($ch, CURLOPT_REFERER, $referer);
       //curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
       $document = curl_exec($ch);
       curl_close($ch);
       return $document;
    }
    $urlpage_data = get_data("http://www.twitter.com/naimtufekci");
    preg_match_all('#<span id="follower_count" class="stats_count numeric">(.*?)</span>#is', $urlpage_data, $urlmatches);
    echo "Tam tamına ". $urlmatches[1][0] ."takipçiniz var.";
    ?>
    Herhangi bir sorun olursa naim@naimtufekci.com mailinden ulaşabilirsin.

    çok teşekkür ederim , bir süredir nete giremiyordumda şimdi incelemeye başlıyorum.