【问题标题】:Posting content from Buffer API从 Buffer API 发布内容
【发布时间】:2019-08-15 21:57:52
【问题描述】:

我已使用此 OAuth 库 https://github.com/thewebguy/bufferapp-php 并尝试将我的缓冲区帖子拉入我的网站。

但是,我不明白如何正确拨打电话并显示内容。

我可以正确访问 API 并发布内容,但我想要解决的是如何在我的网站上显示缓冲帖子中的内容。

我已使用以下代码成功发帖:

<?
session_start();
require('buffer.php');

$client_id = 'xxxxxxxxxxxxxxxxxxxxx';
$client_secret = 'xxxxxxxxxxxxxxxxxxxxxx';
$callback_url = 'http://www.readadvisors.com';

$buffer = new BufferApp($client_id, $client_secret, $callback_url);

if (!$buffer->ok) {
    echo '<a href="' . $buffer->get_login_url() . '">Connect to Buffer!</a>';
} else {
    $profiles = $buffer->go('/profiles');

    if (is_array($profiles)) {
        foreach ($profiles as $profile) {
            //$buffer->go('/updates/create', array('text' => 'My first status update from bufferapp-php worked!', 'profile_ids[]' => $profile->id));
            $buffer->go('/profiles/:id/updates/sent');
        }
    }
}
?>

现在我希望能够将此代码用于其他 API 调用,如下所示:https://buffer.com/developers/api/updates

我对 GET /profiles/:id/updates/sent 特别感兴趣

非常感谢您的帮助!!!

R

【问题讨论】:

  • :id 显然只是一个标记,旨在替换为您感兴趣的配置文件的实际 ID。$buffer-&gt;go('/profiles/'.$profile-&gt;id.'/updates/sent'); 应该可以解决问题。
  • 非常感谢@PatrickQ,但我现在收到一个错误:Catchable fatal error: Object of class stdClass could not be convert to string in /home/readadvisors/readadvisors.com/oauth/example.php on第 19 行,该行显示:'print $buffer->go('/profiles/'.$profile->id.'/updates/sent');'

标签: php api oauth get buffer


【解决方案1】:

你可以使用这个库:https://github.com/miguelbemartin/buffer-sdk-php

而且获取发送的更新真的很简单:

// Create a new AuthorizationToken
$auth = new AuthorizationToken('XXX');

// Create a new Buffer Wrapper Client
$buffer = new Buffer($auth);

// Get Profiles
$profiles = $buffer->profileService->getProfiles();

foreach ($profiles as $profile) {
   $updates = $buffer->updateService->getSentUpdates($profile["id"]);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-09
    • 1970-01-01
    • 1970-01-01
    • 2014-03-08
    • 1970-01-01
    • 1970-01-01
    • 2019-05-04
    • 1970-01-01
    相关资源
    最近更新 更多