-1

クライアントの最新のツイートを取得しようとしています。グーグルで検索した後、私はいくつかのコードを手に入れました。残念ながら、コードはローカルホストで機能していますが、ホスティングサーバーでは機能していません。そのことわざはサーバーを見つけることができませんでした。コードスナップショットを投稿しています。

<?php

            function getTwitterStatus($userid){
            $url = "http://twitter.com/statuses/user_timeline/$userid.xml?count=1";

            $xml = simplexml_load_file($url) or die("could not connect");

            foreach($xml->status as $status){
            $text = $status->text;
            }
            echo $text;
            }

            //my user id AmitEducation
            getTwitterStatus("AmitEducation");

            ?> 

私を助けてください。誰かがより良い提案があれば私を助けてください。

4

2 に答える 2

3

Twitter Search APIを使用してください。本当に素晴らしいです。そしてJSONです。[+1]

$tweets = json_decode(file_get_contents("http://search.twitter.com/search.json?q=php&rpp=5&include_entities=true&result_type=mixed"));

foreach($tweets->results as $t){

  echo "Username: {$t->from_user_name}";
  echo "Tweet: {$t->text}" . PHP_EOL;

} 

使用方法と例については、ドキュメントを参照してください。

于 2012-09-10T15:29:05.067 に答える
0

リンクのユーザー名を変更する

    <?php
      $json = file_get_contents("http://twitter.com/status/user_timeline/username.json?count=10", true); //getting the file content
      $decode = json_decode($json, true); //getting the file content as array
      print_r($decode);
    ?>
于 2012-09-10T15:43:49.100 に答える