发布于2023-11-29 20:02 阅读(996) 评论(0) 点赞(24) 收藏(1)
如果有人已经在某处回答过这个问题,我深表歉意 - 我已经在 Stack 和 Google 上搜索了几个小时,但找不到正确的答案。我正在使用 Abraham 的 TwitterOAuth 并成功地显示了我以前的推文。但是,我想制作一个表格,允许我将新推文发布到我的帐户。该表单似乎在刷新页面时发布,但推文并未发布到我的帐户 - 非常感谢任何帮助!
这是当前的设置:(我已从这篇文章中删除了密钥)
<?php
//keys
$consumer_key = '###';
$consumer_secret = '###';
$access_token = '###';
$access_token_secret = '###';
//include library
require "twitteroauth/autoload.php";
use Abraham\TwitterOAuth\TwitterOAuth;
//connect to API
$connection = new TwitterOAuth($consumer_key, $consumer_secret, $access_token, $access_token_secret);
$content = $connection->get("account/verify_credentials");
// create tweet
$new_status = $connection->post("statuses/update", ["status" => ""]);
//get homepage feed
$statuses = $connection->get("statuses/home_timeline", ["count" => 25, "exclude_replies" => true]);
//get my tweets
$profile = $connection->get("statuses/user_timeline", ["count" => 200, "exclude_replies" => true]);
// display first tweet
// echo($profile[0]->text);
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:400,300,700,800,400italic">
<link rel="stylesheet" href="custom.css">
</head>
<body>
<div class="jumbotron text-center" style="font-size:48px">Sunil Tweets</div><br>
<form method="post" action="index.php">
<input type="text" id="tweet" name="new tweet"/>
<input type="submit" value="post tweet"/>
<input type="hidden" action="<?php echo '$new_status';?>"/>
</form>
</body>
</html>
作者:黑洞官方问答小能手
链接:http://www.phpheidong.com/blog/article/550176/754210b448bc46998c6a/
来源:php黑洞网
任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任
昵称:
评论内容:(最多支持255个字符)
---无人问津也好,技不如人也罢,你都要试着安静下来,去做自己该做的事,而不是让内心的烦躁、焦虑,坏掉你本来就不多的热情和定力
Copyright © 2018-2021 php黑洞网 All Rights Reserved 版权所有,并保留所有权利。 京ICP备18063182号-4
投诉与举报,广告合作请联系vgs_info@163.com或QQ3083709327
免责声明:网站文章均由用户上传,仅供读者学习交流使用,禁止用做商业用途。若文章涉及色情,反动,侵权等违法信息,请向我们举报,一经核实我们会立即删除!