• 10-10-2023, 17:42:17
    #1
    Selamun Aleyküm dostlar. Aşağıda ki kod hata veriyor. Sebebini anlayamadım.


    Hata:
    [10-Oct-2023 17:41:46 Europe/Istanbul] PHP Warning: Attempt to read property "text" on null in /home/teknoweb/public_html/erol/begeni.php on line 25







    
    <?php
    
    // TwitterOAuth kütüphanesini yükle
    require_once('TwitterOAuth/autoload.php');
    require_once __DIR__ . '/vendor/autoload.php';
    use Abraham\TwitterOAuth\TwitterOAuth;
    
    // Twitter API kimlik bilgilerini tanımla
    $consumerKey = "code";
    $consumerSecret = "code";
    $accessToken = "code";
    $accessTokenSecret = "code";
    
    // Twitter API bağlantısını oluştur
    $twitterConnection = new TwitterOAuth($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);
    
    // Tweet ID'sini al
    $tweetID = "1711659165314113663";
    
    // Tweeti al
    $tweet = $twitterConnection->get("statuses/show", ["id" => $tweetID]);
    
    // Tweet metnini ekrana yazdır
    echo $tweet->text;
    
    ?>
  • 10-10-2023, 17:47:41
    #2
    Twitter api free versiyonu mu?
  • 10-10-2023, 17:48:01
    #3
    text null dönmüş. $tweet değişkenini yazdırıp içinde hangi veriler var onları kontrol edin.
    Veya twitter size bir response dönüyor mu ona bakın. Veriyi alamamış olabilirsiniz.
  • 10-10-2023, 17:50:32
    #4
    SwitchAlpha adlı üyeden alıntı: mesajı görüntüle
    Twitter api free versiyonu mu?
    evet hocam ücretsiz versiyon
  • 10-10-2023, 17:50:52
    #5
    Creative08 adlı üyeden alıntı: mesajı görüntüle
    text null dönmüş. $tweet değişkenini yazdırıp içinde hangi veriler var onları kontrol edin.
    Veya twitter size bir response dönüyor mu ona bakın. Veriyi alamamış olabilirsiniz.
    print $tweet;

    yaptım yine ekran boş.
  • 10-10-2023, 17:52:52
    #6
    Free versiyonda tweet çekemezsiniz sadece tweet gönderebilirsiniz
  • 10-10-2023, 17:54:54
    #7
    sebebi budur hocam: PHP Warning: Attempt to read property "text" on null in
  • 10-10-2023, 17:56:31
    #8
    hkey adlı üyeden alıntı: mesajı görüntüle
    sebebi budur hocam: PHP Warning: Attempt to read property "text" on null in
    twitter da veri çekmiyor ki okusun hocam.
  • 10-10-2023, 18:03:12
    #9
    SwitchAlpha adlı üyeden alıntı: mesajı görüntüle
    Free versiyonda tweet çekemezsiniz sadece tweet gönderebilirsiniz

    Twit gönderme de 404 hatası verdi.

    Hata:




    
    <?php
    
    // TwitterOAuth kütüphanesini yükle
    require_once('TwitterOAuth/autoload.php');
    require_once __DIR__ . '/vendor/autoload.php';
    use Abraham\TwitterOAuth\TwitterOAuth;
    
    // Twitter API kimlik bilgilerini tanımla
    $consumerKey = "code";
    $consumerSecret = "code";
    $accessToken = "code";
    $accessTokenSecret = "code";
    
    if (!$consumerKey || !$consumerSecret || !$accessToken || !$accessTokenSecret) {
        die("Twitter API kimlik bilgileri eksik. Lütfen doğru kimlik bilgilerini ayarlayın.");
    }
    
    // Twitter API bağlantısını oluştur
    $twitterConnection = new TwitterOAuth($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);
    
    // Tweet metnini ayarlayın
    $tweet = "Selam nasılsınız?";
    
    // Tweet'i gönder
    $status = $twitterConnection->post('statuses/update', ['status' => $tweet]);
    
    // Tweet başarıyla gönderildiyse, başarı mesajını göster
    if ($twitterConnection->getLastHttpCode() == 200) {
        echo "Tweet başarıyla gönderildi!";
    } else {
        echo "Tweet gönderme hatası: " . $twitterConnection->getLastHttpCode();
    }
    
    ?>