Reddit api sdk 什么都不做,返回 null [英] Reddit api sdk doing nothing, returns null

查看:59
本文介绍了Reddit api sdk 什么都不做,返回 null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to use this reddit php api wrapper https://github.com/jcleblanc/reddit-php-sdk

向 reddit 提交帖子.

To submit a post to reddit.

代码看起来很简单,我知道我配置正确.

The code seems very simple, and I know I have it configured correct.

当我加载页面时,它会转到 reddit,验证我的帐户,然后将我发回.但是不发帖.如果我刷新,什么都不会发生.如果我删除会话 cookie,它会再次进行验证确认,但从不提交帖子.

When I load the page, it will go to reddit, verify my account, then send me back. But doesn't make the post. If I refresh, nothing happens. If I delete the session cookie, it does the verification confirmation again, but never submits a post.

我设置了 api,获得了正确的应用程序 ID 和密码,重定向 uri 是正确的,它返回到我的页面.

I set up the api, got the right app id and secret, the redirect uri is right, it comes back to my page.

<?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,所以我不知道去哪里找

the dump just returns null, so I don't know where to look

我知道这有点晦涩,但有什么想法吗?

I know it's kind of obscure, but any ideas?

推荐答案

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

A subreddit post will return null, based on my experience with the code from jcleblanc. His code is not working when i pulled it, but another person fixed it. Pull this https://github.com/markdavison/reddit-php-sdk/commit/2c2eac7f2202720e3fbb80b1ef48c87a6a213ff6

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

Then run that code. Except you are missing the getuser function which is required at all calls to the reddit api.

其他调用将返回数据,例如 getlisting 等,您将看到已提交的帖子和正在运行的命令.

Other calls will return data, such as getlisting, etc and you will see posts submitted and the commands working.

如果您需要代码,请询问,因为我已经编写了所有基本功能.

If you need code, please ask as I have all basic functions coded.

这是我的 subreddit 代码调用,带有 git hub 更改

Here is my subreddit code call with the git hub changes

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);
?>

这篇关于Reddit api sdk 什么都不做,返回 null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆