[英]Twitter API OAuth PHP post_tweet.php
從php發布推文后,我無法獲得任何結果。 我已經在Twitter上注冊了我的應用程序並獲得了我的憑據。 我制作了一個名為access_tokens.php的頁面,並下載了一個名為tmhOAuth.php的OAuth庫。 我正在完全按照示例教程進行操作,似乎什么也沒出現-是否可以提供任何幫助?
access_tokens.php
<?php
$consumer_key = 'xx';
$consumer_secret = 'xx';
$user_token = 'xx';
$user_secret = 'xx';
//xx is the replacement for my actual values
?>
post_tweet.php
<?php
//Load the app's keys into memory
require 'app_tokens.php';
//Load the tmOAuth library
require 'tmhOAuth.php';
//Create an OAuth connection to the Twitter API
$connection = new tmhOAut(array(
'consumer_key' => $consumer_key,
'consumer_secret'=> $consumer_secret,
'user_token' => $user_token,
'user_secret' => $user_secret
));
//Send a tweet
$code = $connection -> request('POST',
$connection -> url('1.1/statuses/update'),
array('status' => 'Hello Twitter'));
//A response code of 200 is a success
if ($code == 200){
print "Tweet sent";
}
else{
print "Error:$code";
}
?>
查找該OAuth庫是否已受支持,因為幾個月前我試圖做同樣的事情,並且發現一些帖子告訴我們,自3月以來,它不再可用。 無論如何,我不確定這是否是該庫,但是如果您編寫與twitter相關的代碼,則必須知道它們經常更改其API。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.