2014-01-24 74 views
0

我在某個時間研究如何通過編程在twitter上發佈出版物,但在此之前,我得到了我將在下面展示的代碼,只有即使設置了一切正確的還沒有發送,有沒有人有任何建議的設置,我必須忘記這樣做發送完成?在Twitter上發佈使用PHP(OAuth)亞伯拉罕·威廉姆斯

記住的是,我使用的TwiterrOAuth 亞伯拉罕·威廉姆斯,已經申請了1.1 API。 (最新版本的GIT)

以下是代碼。

<?php 

// Insert your keys/tokens 

$consumerKey = 'CONSUMER'; 
$consumerSecret = 'CSECRET'; 
$OAuthToken = 'TOKEN'; 
$OAuthSecret = 'TSECRET'; 

// Full path to twitterOAuth.php (change OAuth to your own path) 
require_once('twitteroauth.php'); 

// create new instance 
$tweet = new TwitterOAuth($consumerKey, $consumerSecret, $OAuthToken, $OAuthSecret); 

// Your Message 
$message = "This is a test message."; 

// Send tweet 
$tweet->post('statuses/update', array('status' => "$message")); 

?> 

已經在網站上的幾個帖子中進行了研究,並沒有給我的問題帶來任何解決方案。記住你沒有任何回報,只是沒有任何反應。

我的應用程序設置爲在Twitter上讀寫。

$ tweet-> post返回false如果我檢查它。

這是什麼的var_dump($鳴叫)返回

object(TwitterOAuth)#1 (13) { 
["http_code"]=> int(0) 
["url"]=> string(48) "https://api.twitter.com/1.1/statuses/update.json" 
["host"]=> string(28) "https://api.twitter.com/1.1/" 
["timeout"]=> int(30) 
["connecttimeout"]=> int(30) 
["ssl_verifypeer"]=> bool(false) 
["format"]=> string(4) "json" 
["decode_json"]=> bool(true) 
["http_info"]=> array(20) { 
    ["url"]=> string(48) "https://api.twitter.com/1.1/statuses/update.json" 
    ["content_type"]=> NULL 
    ["http_code"]=> int(0) 
    ["header_size"]=> int(0) 
    ["request_size"]=> int(0) 
    ["filetime"]=> int(-1) 
    ["ssl_verify_result"]=> int(0) 
    ["redirect_count"]=> int(0) 
    ["total_time"]=> float(30.02972) 
    ["namelookup_time"]=> float(0.058814) 
    ["connect_time"]=> float(0) 
    ["pretransfer_time"]=> float(0) 
    ["size_upload"]=> float(0) 
    ["size_download"]=> float(0) 
    ["speed_download"]=> float(0) 
    ["speed_upload"]=> float(0) 
    ["download_content_length"]=> float(-1) 
    ["upload_content_length"]=> float(-1) 
    ["starttransfer_time"]=> float(0) 
    ["redirect_time"]=> float(0) } 
["useragent"]=> string(25) "TwitterOAuth v0.2.0-beta2" 
["sha1_method"]=> object(OAuthSignatureMethod_HMAC_SHA1)#2 (0) { } 
["consumer"]=> object(OAuthConsumer)#3 (3) { 
    ["key"]=> string(22) "uqZ5yUGoofxxxxxxxxxxx" 
    ["secret"]=> string(40) "fGpJERhrIAB9RIyQEExxxxxxxxxxx" 
    ["callback_url"]=> NULL 
} 
["token"]=> object(OAuthConsumer)#4 (3) { 
    ["key"]=> string(50) "49596683-Sxxxxxxxxxxxxxxxxxx" 
    ["secret"]=> string(40) "v3Q6pAeE4t1YXaGxxxxxxxxxxxxxx" 
["callback_url"]=> NULL 
} 
} 

的$主機變量。

public $host = "https://api.twitter.com/1.1/"; 

回答

0

嘗試增加..

$tweet = new TwitterOAuth($consumerKey, $consumerSecret, $OAuthToken, $OAuthSecret) 
$tweet->get('account/verify_credentials'); //<--- Add this. 
+0

嗯,這個沒有工作,有另一個想法? – gabrielbuzzi

+0

@GabrielBuzziVenturi,我已經有這個工作正常。什麼是你的'var_dump' ..就像'var_dump($ tweet-> get('account/verify_credentials'));' –

+0

返回NULL,也許它是我的應用程序中的配置不正確? – gabrielbuzzi

相關問題