duanjianfu1398 2019-08-02 14:12
浏览 112
已采纳

发布tumblr api禁止

I need to make a post in tumblr using the tumblr api.

Using the official tumblr php wrapper is not working, if i do a post method. When doing a get method it works fine i will get all the information i need.

I commented the get method. So you have a idea


    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
        $tumblrId = $request->get('tumblr_id');
        $table = DB::table('tumblr_tables')->where('id', $tumblrId);
        $blogName = $request->get('title');
        $body = $request->get('body');
        $createdAt= $request->get('created_at');
        $consumerKey = $table->value('consumer_key');
        $consumerSecret = $table->value('consumer_secret');
        $consumerToken= $table->value('tumblr_token');
        $tumblrSecret = $table->value('tumblr_secret');

        $data = [$body, $createdAt];

        // Authenticate via OAuth
        $client = new Client($consumerKey, $consumerSecret);
        $client->setToken($consumerToken, $tumblrSecret);
//        foreach ($client->getUserInfo()->user->blogs as $blog) {
//            echo $blog->name . "
";
//        }

        $client->createPost($blogName, $data);

//        return response(redirect(route('voyager.posts.index'))->with(['message' => "Your post created", 'alert-type' => 'success']));
        return response('hello world');

    }

I expect to see a new post on my tumblr page

  • 写回答

1条回答 默认 最新

  • douzhan2027 2019-08-02 15:00
    关注

    Thanks to @GrumpyCrouton

    $blogName should be the name of the blog you are posting to

    $client->createPost($blogName, $data);

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分