本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

使用 PHP 和 TwitterOAUTH 使用表单发布推文

发布于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黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

24 0
收藏该文
已收藏

评论内容:(最多支持255个字符)