Публикация в Tumblr с помощью PHP и Tumblr APIPhp

Кемеровские программисты php общаются здесь
Ответить Пред. темаСлед. тема
Гость
 Публикация в Tumblr с помощью PHP и Tumblr API

Сообщение Гость »


I am trying to post messages automatically to my Tumblr Blog (which will run daily via Cron)

I am using the Official Tumblr PHP library here: https://github.com/tumblr/tumblr.php

And using the Authentication method detailed here : https://github.com/tumblr/tumblr.php/wi ... entication (or parts of this, as I don't need user input!)

I have the below code

Код: Выделить всё

require_once('vendor/autoload.php'); // some variables that will be pretttty useful $consumerKey = 'MY-CONSUMER-KEY'; $consumerSecret = 'MY-CONSUMER-SECRET'; $client = new Tumblr\API\Client($consumerKey, $consumerSecret); $requestHandler = $client->getRequestHandler(); $blogName = 'MY-BLOG-NAME'; $requestHandler->setBaseUrl('https://www.tumblr.com/'); // start the old gal up $resp = $requestHandler->request('POST', 'oauth/request_token', array()); // get the oauth_token $out = $result = $resp->body; $data = array(); parse_str($out, $data); // set the token $client->setToken($data['oauth_token'], $data['oauth_token_secret']); // change the baseURL so that we can use the desired Methods $client->getRequestHandler()->setBaseUrl('http://api.tumblr.com'); // build the $postData into an array $postData = array('title' => 'test title', 'body' => 'test body'); // call the creatPost function to post the $postData $client->createPost($blogName, $postData); 
However, this gives me the following error:

Fatal error: Uncaught Tumblr\API\RequestException: [401]: Not Authorized thrown in /home///*/vendor/tumblr/tumblr/lib/Tumblr/API/Client.php on line 426

I can retrieve blog posts and other data fine with (example):

Код: Выделить всё

echo ''; print_r( $client->getBlogPosts($blogName, $options = null) ); echo ''; 
So it seems it is just making a post that I cant manage.

In all honesty, I don't really understand the OAuth Authentication, so am using code that more worthy coders have kindly provided free :-) I assume I am OK to have edited out parts of the https://github.com/tumblr/tumblr.php/wi ... entication as I don't need user input as this is just going to be code ran directly from my server (via Cron)

I have spent days looking around the internet for some answers (have gotten a little further), but am totally stuck on this one...

Any advice is much appreciated!


Источник: https://stackoverflow.com/questions/213 ... tumblr-api
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • Публикация в Tumblr с помощью PHP и Tumblr API
    Anonymous » » в форуме Php
    0 Ответы
    15 Просмотры
    Последнее сообщение Anonymous
  • Размещение в Tumblr с PHP и Tumblr API
    Anonymous » » в форуме Php
    0 Ответы
    7 Просмотры
    Последнее сообщение Anonymous
  • Публикация тем задерживается. Первоначально публикация тем в OPENDDS занимает 5 секунд.
    Гость » » в форуме C#
    0 Ответы
    65 Просмотры
    Последнее сообщение Гость
  • Публикация тем задерживается. Первоначально публикация тем в OPENDDS занимает 5 секунд.
    Гость » » в форуме C++
    0 Ответы
    101 Просмотры
    Последнее сообщение Гость
  • Публикация тем задерживается. Первоначально публикация тем в OPENDDS занимает 5 секунд [закрыто]
    Гость » » в форуме C#
    0 Ответы
    69 Просмотры
    Последнее сообщение Гость

Вернуться в «Php»