“显示最新推特订阅源”;“创建日期”;使用tmhOAuth和PHP

“显示最新推特订阅源”;“创建日期”;使用tmhOAuth和PHP,php,twitter,Php,Twitter,自从TwitterAPI v1“退役”以来,我一直在寻找一种使用PHP显示最新Twitter提要的新方法,我找到了“Thematthharris/tmhOAuth”(OAuth 1.0A用PHP编写的库),可以在GitHub下载: 我查了一下谷歌,在使用上述图书馆时发现了两个有用的链接: 由于以下链接,我能够显示最新的twitter提要。以下是我的PHP代码: require '../class/tmhOAuth/tmhOAuth.php'; require '../class/t

自从TwitterAPI v1“退役”以来,我一直在寻找一种使用PHP显示最新Twitter提要的新方法,我找到了“Thematthharris/tmhOAuth”(OAuth 1.0A用PHP编写的库),可以在GitHub下载:

我查了一下谷歌,在使用上述图书馆时发现了两个有用的链接:

由于以下链接,我能够显示最新的twitter提要。以下是我的PHP代码:

require '../class/tmhOAuth/tmhOAuth.php';
require '../class/tmhOAuth/tmhUtilities.php';

$tmhOAuth = new tmhOAuth(array(
  'consumer_key' => 'xxx',
  'consumer_secret' => 'xxx',
  'user_token' => 'xxx',
  'user_secret' => 'xxx',
));

$code = $tmhOAuth->request('GET', $tmhOAuth->url('1.1/statuses/user_timeline'), array(
'screen_name' => 'xxx',
'count' => '1'));

$response = $tmhOAuth->response['response'];
$twitFeed = json_decode($response, true);   

$twitFeed = $twitFeed[0]['text'];
$twitFeed = preg_replace("/([\w]+\:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/", "<a target=\"_blank\" href=\"$1\">$1</a>", $twitFeed);
$twitFeed = preg_replace("/#([A-Za-z0-9\/\.]*)/", "<a target=\"_new\" href=\"http://twitter.com/search?q=$1\">#$1</a>", $twitFeed);
$twitFeed = preg_replace("/@([A-Za-z0-9\/\.]*)/", "<a href=\"http://www.twitter.com/$1\">@$1</a>", $twitFeed);
echo($twitFeed);
但它给了我“注意:在第xx行的http:localhost/try.php中尝试获取非对象的属性”,它指向“$feedDate=$item->created_at;”


我对Twitter API还是有点陌生。。。请帮助…

Opps,我刚刚得到了我困境中的解决方案,无论如何我都会将代码分享给任何人

<?php
$twitter_id = "your_twitter_id";
$no_of_Feeds = 1;

require "class/tmhOAuth/tmhOAuth.php";
require "class/tmhOAuth/tmhUtilities.php";

$tmhOAuth = new tmhOAuth(array(
'consumer_key' => 'your_consumer_key',
'consumer_secret' => 'your_consumer_secret',
'user_token' => 'your_user_token',
'user_secret' => 'your_user_secret',
));

$code = $tmhOAuth->request('GET', $tmhOAuth->url('1.1/statuses/user_timeline'), array(
'screen_name' => $twitter_id,
'count' => $no_of_Feeds));

$response = $tmhOAuth->response['response'];
$twitFeed = json_decode($response, true);

foreach ($twitFeed as $latestFeed) {
$feedDate = $latestFeed["created_at"];
$postedLast = explode(" ", $feedDate);
$feedCreatedAt = $postedLast[0]." - ".$postedLast[1]." ".$postedLast[2].", ".$postedLast[5];
$feedMsg = $latestFeed["text"];
$feedMsg = preg_replace("/([\w]+\:\/\/[\w-?&;#~=.\/\@]+[\w\/])/", "<a target="_blank" href="$1">$1</a>", $feedMsg);
$feedMsg = preg_replace("/#([A-Za-z0-9\/.]*)/", "<a target="_new" href="http://twitter.com/search?q=$1">#$1</a>", $feedMsg);
$feedMsg = preg_replace("/@([A-Za-z0-9\/.]*)/", "<a href="http://www.twitter.com/$1">@$1</a>", $feedMsg);
}
?>


<a href="https://twitter.com/<?php echo $twitter_id; ?>" target="_blank">@<?php echo $twitter_id; ?></a> <b>said:</b> <?php echo $feedMsg; ?> <b>last</b> <?php echo $feedCreatedAt; ?><br />

说:最后一次
刚刚将“$item->created_at”替换为“$latestFeed[“created_at”]”

<?php
$twitter_id = "your_twitter_id";
$no_of_Feeds = 1;

require "class/tmhOAuth/tmhOAuth.php";
require "class/tmhOAuth/tmhUtilities.php";

$tmhOAuth = new tmhOAuth(array(
'consumer_key' => 'your_consumer_key',
'consumer_secret' => 'your_consumer_secret',
'user_token' => 'your_user_token',
'user_secret' => 'your_user_secret',
));

$code = $tmhOAuth->request('GET', $tmhOAuth->url('1.1/statuses/user_timeline'), array(
'screen_name' => $twitter_id,
'count' => $no_of_Feeds));

$response = $tmhOAuth->response['response'];
$twitFeed = json_decode($response, true);

foreach ($twitFeed as $latestFeed) {
$feedDate = $latestFeed["created_at"];
$postedLast = explode(" ", $feedDate);
$feedCreatedAt = $postedLast[0]." - ".$postedLast[1]." ".$postedLast[2].", ".$postedLast[5];
$feedMsg = $latestFeed["text"];
$feedMsg = preg_replace("/([\w]+\:\/\/[\w-?&;#~=.\/\@]+[\w\/])/", "<a target="_blank" href="$1">$1</a>", $feedMsg);
$feedMsg = preg_replace("/#([A-Za-z0-9\/.]*)/", "<a target="_new" href="http://twitter.com/search?q=$1">#$1</a>", $feedMsg);
$feedMsg = preg_replace("/@([A-Za-z0-9\/.]*)/", "<a href="http://www.twitter.com/$1">@$1</a>", $feedMsg);
}
?>


<a href="https://twitter.com/<?php echo $twitter_id; ?>" target="_blank">@<?php echo $twitter_id; ?></a> <b>said:</b> <?php echo $feedMsg; ?> <b>last</b> <?php echo $feedCreatedAt; ?><br />