使用 php 发布到 tumblr [英] post to tumblr using php

查看:24
本文介绍了使用 php 发布到 tumblr的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能帮我弄清楚如何使用 php 发布到 tumblr.我尝试在谷歌上搜索库或示例代码,但找不到.我只能在这里找到这个 https://github.com/alexdunae/tumblr-php/blob/master/Tumblr.php,它似乎也不起作用我在 tumblr 网站上查看并尝试了 v1 api 上的代码,但也不起作用......

Could anyone help me figure out how to post to tumblr using php. I tried googling for a library or a sample code but couldn't find one. all I can find is this here https://github.com/alexdunae/tumblr-php/blob/master/Tumblr.php and it doesnt seem to work also I looked and tried the code on v1 api at tumblr website that doesnt work either ....

 function post($data){
                if(function_exists("curl_version")){
                        $data["email"] = $this->email;
                        $data["password"] = $this->password;
                        $data["generator"] = $this->generator;
                        $request = http_build_query($data);
                        $c = curl_init('http://www.tumblr.com/api/write');
                        curl_setopt($c,CURLOPT_POST,true);
                        curl_setopt($c,CURLOPT_POSTFIELDS,$request);
                        curl_setopt($c,CURLOPT_RETURNTRANSFER,true);
                        $return = curl_exec($c);
                        $status = curl_getinfo($c,CURLINFO_HTTP_CODE);
                        curl_close($c);
                        if($status == "201"){
                            return true;
                        }
                        elseif($status == "403"){
                            return false;
                        }
                        else{
                            return "error: $return";
                        }
                }
                else{
                        return "error: cURL not installed";
                }
        }

感谢您的帮助

推荐答案

我刚刚注意到这显示为 Tumblr 精选,我想说的是:截至 2012 年,你应该忽略 Tuga 的上述答案,因为它不适用于最新的 Tumblr API.

I just noticed that this is showing up as Featured for Tumblr and I want to say this: As of 2012, you should IGNORE the above answer by Tuga because it DOES NOT work with the newest Tumblr API.

您需要的是 TumblrOAuth,它是从 OAuth 沙盒.

What you need is TumblrOAuth which is built from OAuth Sandbox.

它仅设置为读取和写入 Tumblr 帖子,因此如果您想做更多事情,则需要更改代码.我将其用作 Followr 的代码库.

It is only setup to read and write Tumblr posts, so if you want to do more than that, you'll need to alter the code. I used it as my code base for Followr.

这篇关于使用 php 发布到 tumblr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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