Tôi sử dụng mã bên dưới để truy xuất tweet của tôi và json echo. Điều này hoạt động tốt.cách đăng tweet bằng cách sử dụng twitter 1.1 api và twitteroauth
<?php
session_start();
require_once('includes/twitter/twitteroauth.php');
$twitteruser = "xxxxxx";
$notweets = 3;
$consumerkey = "xxxxxxx";
$consumersecret = "xxxxxx";
$accesstoken = "xxxxxxxx";
$accesstokensecret = "xxxxxx";
$connection = new TwitterOAuth($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);
$tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitteruser."&count=".$notweets);
echo json_encode($tweets);
?>
Bây giờ tôi muốn gửi một tweet bằng cách sử dụng mã tương tự nhưng nó không hoạt động. Tôi không chắc liệu cú pháp gửi có chính xác hay không. vì vậy xin vui lòng ai đó giúp tôi.
<?php
session_start();
require_once('includes/twitter/twitteroauth.php'); //Path to twitteroauth library
$twitteruser = "xxxxxx";
$notweets = 3;
$consumerkey = "xxxxxxx";
$consumersecret = "xxxxxx";
$accesstoken = "xxxxxxxx";
$accesstokensecret = "xxxxxx";
// start connection
$connection = new TwitterOAuth($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);
//message
$message = "Hi how are you";
//send message
$status = $connection->post('https://api.twitter.com/1.1/statuses/update.json', array('status' => $message));
?>
Chúng tôi có nhận được id tweet và thời gian như một phản ứng? –
Tôi muốn chuyển thông số 'url' khác với 'trạng thái' là có thể – RaviPatidar