2014-10-04 35 views
1

我試圖用這個reddit的PHP API包裝 https://github.com/jcleblanc/reddit-php-sdkreddit的API SDK無所事事,返回null

要提交後到reddit。

該代碼看起來很簡單,我知道我已配置正確。

當我加載頁面,它會去reddit,驗證我的帳戶,然後送我回來。但不發表帖子。如果我刷新,沒有任何反應。如果我刪除會話cookie,它會再次執行驗證確認,但不會提交帖子。

我設置了api,得到了正確的應用程序ID和祕密,重定向uri是正確的,它回到了我的頁面。

<?php 
echo '<h1>Test</h1>'; 

require_once("reddit.php"); 
$reddit = new reddit(); 

$title = "Test submission Google"; 
$link = "http://google.com/"; 
$subreddit = "truepixelart"; 
$response = $reddit->createStory($title, $link, $subreddit); 

var_dump($response); 
?> 

轉儲剛剛返回null,所以我不知道去哪裏找

我知道這是一種模糊的,但任何想法?

回答

2

根據我對jcleblanc的代碼的經驗,一個subreddit post將返回null。當我拉它時,他的代碼不工作,但另一個人修復了它。拉這個 https://github.com/markdavison/reddit-php-sdk/commit/2c2eac7f2202720e3fbb80b1ef48c87a6a213ff6

然後運行該代碼。除了缺少在所有對reddit api的調用所需的getuser函數外。

其他調用將返回數據,如getlist等,你會看到提交的帖子和命令的工作。

如果您需要代碼,請詢問我所有的基本功能編碼。

這裏是git的樞紐我版(Subreddit)代碼調用改變

[email protected]:~/centmedes/wordpress/reddit-php-sdk$ cat submitstory.php 
<?php 
require_once("reddit.php"); 
$reddit = new reddit(); 
$userData = $reddit->getUser(); 
$title = "MakerBot test 3 Releases IPad App For Easy 3D Printing"; 
$link = "http://makezine.com/greg"; 
$subreddit = "cbtest"; 
$response = $reddit->createStory($title, $link, $subreddit); 
var_dump($response); 
?> 
相關問題