400 Bad Request Pengguna tidak terdaftar dengan layanan HTML. service To enable the service please contact https://twitter.com/staticallyio

400 Bad Request. The user is not registered with the HTML service. To enable the service please contact https://twitter.com/staticallyio

Saya menggunakan kode berikut untuk mengambil sejumlah Tweet dari API Twitter:

$cache_file = "cache/$username-twitter.cache";
$last = filemtime($cache_file);
$now = time();
$interval = $interval * 60; // ten minutes

// Check the cache file age
if ( !$last || (( $now - $last ) > $interval) ) {
    // cache file doesn't exist, or is old, so refresh it

    // Get the data from Twitter JSON API
    //$json = @file_get_contents("http://api.twitter.com/1/statuses/user_timeline.json?screen_name=" . $username . "&count=" . $count, "rb");
    $twitterHandle = fopen("http://api.twitter.com/1/statuses/user_timeline.json?screen_name=$username&count=$count", "rb");
    $json  = stream_get_contents($twitterHandle);
    fclose($twitterHandle);

    if($json) {
        // Decode JSON into array
        $data = json_decode($json, true);
        $data = serialize($data);

        // Store the data in a cache
        $cacheHandle = fopen($cache_file, 'w');
        fwrite($cacheHandle, $data);
        fclose($cacheHandle);
    }

}

// read from the cache file with either new data or the old cache
$tweets = @unserialize(file_get_contents($cache_file));

return $tweets;

Tentu saja $username dan variabel lain di dalam permintaan fopen sudah benar dan itu menghasilkan URL yang benar karena saya mendapatkan kesalahan:

Warning: fopen(http://api.twitter.com/1/statuses/user_timeline.json?screen_name=Schodemeiss&count=5) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in /home/ellexus1/public_html/settings.php on line 187

bahwa ^^ error kembali setiap kali saya mencoba dan membuka halaman saya.

Adakah ide mengapa hal ini terjadi? Apakah saya perlu menggunakan OAuth untuk mendapatkan tweet saya saja !? Apakah saya harus mendaftarkan situs web saya sebagai tempat yang mungkin mendapatkan posting?

Saya benar-benar tidak yakin mengapa ini terjadi. Tuan rumah saya adalah JustHost.com, tetapi saya tidak yakin apakah itu membuat perbedaan. Semua ide dipersilakan!

Terima kasih.

Shannenpio

Perhatian!!. Kode ini terletak di dalam fungsi di mana nama pengguna, interval, dan jumlah diteruskan dengan benar, maka dalam kode kesalahan itu dibuat alamat yang terbentuk dengan baik.

You Might Also Like:

Disqus Comments