Reddit api sdk什么都不做,返回null

时间:2014-10-04 23:28:26

标签: php reddit

我正在尝试使用这个reddit php api包装器 https://github.com/jcleblanc/reddit-php-sdk

向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,所以我不知道在哪里看

我知道这有点模糊,但有什么想法吗?

1 个答案:

答案 0 :(得分:2)

根据我对jcleblanc代码的使用经验,subreddit帖子将返回null。当我拉它时,他的代码不起作用,但另一个人修复了它。拉这个 https://github.com/markdavison/reddit-php-sdk/commit/2c2eac7f2202720e3fbb80b1ef48c87a6a213ff6

然后运行该代码。除非您缺少所有调用reddit api所需的getuser函数。

其他调用将返回数据,例如getlisting等,您将看到提交的帖子和命令正常工作。

如果您需要代码,请询问我是否已编码所有基本功能。

这是我使用git hub更改的subreddit代码调用

ioudas@centralmainedesigns:~/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);
?>
相关问题