tumblr API 获取帖子评论

发布于 2024-11-24 02:15:07 字数 1479 浏览 3 评论 0原文

 <?php
 $numPosts = 5;

  $feedURL = "http://#######.tumblr.com/api/read/?num=$numPosts";

   $xml = @simplexml_load_file($feedURL);

  foreach(@$xml->posts->post as $post){
  $posts = (string) $post->{'photo-caption'}; 
  $img = (string) $post->{'photo-url'};
   echo "<div style='width:518px;height:600px;'><div style='width:518px;height:200px;  float:left;'>".'<img style="width:200px;height:200px;" src="' . $img . '" />'."</div><div style='width:518px;height:300px;float:left;'>".$posts."</div></div><br>";}

 ?>
   <div id="disqus_thread"></div>
    <script type="text/javascript">
    /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'creativescripters'; // required: replace example with your forum shortname

// The following are highly recommended additional parameters. Remove the slashes in front to use.
 var disqus_identifier = 'unique_dynamic_id_1234';
var disqus_url = 'http://creativescripters.com/samples/tab/tab7.html';

/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
    var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
    dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();

在这里,我正在获取帖子,但我想获取针对特定帖子的评论。

 <?php
 $numPosts = 5;

  $feedURL = "http://#######.tumblr.com/api/read/?num=$numPosts";

   $xml = @simplexml_load_file($feedURL);

  foreach(@$xml->posts->post as $post){
  $posts = (string) $post->{'photo-caption'}; 
  $img = (string) $post->{'photo-url'};
   echo "<div style='width:518px;height:600px;'><div style='width:518px;height:200px;  float:left;'>".'<img style="width:200px;height:200px;" src="' . $img . '" />'."</div><div style='width:518px;height:300px;float:left;'>".$posts."</div></div><br>";}

 ?>
   <div id="disqus_thread"></div>
    <script type="text/javascript">
    /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'creativescripters'; // required: replace example with your forum shortname

// The following are highly recommended additional parameters. Remove the slashes in front to use.
 var disqus_identifier = 'unique_dynamic_id_1234';
var disqus_url = 'http://creativescripters.com/samples/tab/tab7.html';

/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
    var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
    dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();

Here i am fetching the posts, but i want to fetch comments that are given to a particular post..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

堇年纸鸢 2024-12-01 02:15:07

Tumblr 中的评论称为注释。

有关详细信息,请参阅 API 文档 - /posts - 部分。

对于您的具体问题,您只需根据 API 请求将布尔值 notes_info 设置为 true 即可。例如:

通用API post请求
http://api.tumblr.com/v2/blog/peacecorps.tumblr.com/posts/text?api_key=PyezS3Q4Smivb24d9SzZGYSuhMNPQUhMsVetMC9ksuGPkK1BTt¬es_info

带注释的帖子的 API 请求
http://api.tumblr.com/v2/blog/peacecorps.tumblr.com/posts/text?api_key=PyezS3Q4Smivb24d9SzZGYSuhMNPQUhMsVetMC9ksuGPkK1BTt¬es_info=true

因此,只需更改您的 Feed URL 即可走吧。

The comments in Tumblr are known as notes.

See the API documentation - /posts - section for details.

For your specific question, you just have to set the Boolean notes_info to true on API request. For example:

General API post request
http://api.tumblr.com/v2/blog/peacecorps.tumblr.com/posts/text?api_key=PyezS3Q4Smivb24d9SzZGYSuhMNPQUhMsVetMC9ksuGPkK1BTt¬es_info

API request for post with notes
http://api.tumblr.com/v2/blog/peacecorps.tumblr.com/posts/text?api_key=PyezS3Q4Smivb24d9SzZGYSuhMNPQUhMsVetMC9ksuGPkK1BTt¬es_info=true

So just change your feed URL and you should be good to go.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文