【问题标题】:CakePHP 2.0 LinkedIn Plugin - Post a share?CakePHP 2.0 LinkedIn 插件 - 发布分享?
【发布时间】:2012-01-11 18:50:32
【问题描述】:

我正在为 CakePHP 2.0.4 使用这个 LinkedIn 插件:https://github.com/ProLoser/CakePHP-LinkedIn

我设置了一切,以便在登录时正常工作,并使用以下语法获取用户的个人资料,如名字、姓氏……:$this->Linkedin->find("all",...)。我将 Linkedin 数据源的默认名称“Linkedin”重命名为“LinkedinSource”,因此为了方便起见,我可以将模型称为“Linkedin”。

我按照文件 /Plugin/Linkedin/Model/LinkedinMessage.php 在我的 Linkedin 模型中创建了这个函数:

function updateStatus($message) {
    $request = $this->request;
    $request['uri']['path'] = 'people/~/shares';
    $this->request = $request;
    //Above 3 lines are used to bypass the error "changing value of overloaded object property has no effect if I use $this->request["uri"]["path"] = "..."

    $data = array(
        'comment' => $message
        , 'visibility' => array('code' => 'anyone')
    );
    //Above settings follow this: https://developer.linkedin.com/documents/share-api

    $saved = $this->save($data);
}

当我使用我自己的 LinkedIn 帐户(已连接和授权)运行上述代码时,$saved 的值只是 TRUE 但是当我打开我的帐户时,没有状态/共享发布到我的 LinkedIn 帐户在浏览器(谷歌浏览器)上

我尝试将 URI 路径更改为

    $request['uri']['path'] = 'people/~/person-activities';

并将数据请求到:

    $data = array(
        'content-type' => "linkedin-html"
        , 'body' => $message
    );

https://developer.linkedin.com/documents/post-network-update一样,但仍然没有更好的结果。

我也在 /Plugin/Linkedin/Config/LinkedinSource.php 中更改了这些行:

$config['Apis']['LinkedinSource']['write'] = array(
    // http://developer.linkedin.com/docs/DOC-1044
    'mailbox' => array(
        'people/~/mailbox' => array(
            'subject',
            'body',
            'recipients',
        ),
    ),
);

$config['Apis']['LinkedinSource']['write'] = array(
    // http://developer.linkedin.com/docs/DOC-1044
    'mailbox' => array(
        'people/~/mailbox' => array(
            'subject',
            'body',
            'recipients',
        ),
    ),
    //https://developer.linkedin.com/documents/share-api
    'shares' => array(
        'people/~/shares' => array(
            'comment',
            'content',
            'visibility',
        ),
    ),
);

但仍然没有更好的结果。

请注意,我在 /Plugin/Linkedin/Model/LinkedinMessage.php 中添加了这些行

    public $startQuote;
    public $endQuote;

为了避免这些错误:

Undefined property: LinkedinSource::$startQuote [CORE/Cake/Model/Model.php, line 1269]
Undefined property: LinkedinSource::$endQuote [CORE/Cake/Model/Model.php, line 1269]

我不知道这是否会导致我的问题,但我想在这里列出所有详细信息。

请帮忙,因为我花了将近一天的时间来完成这项工作,但仍然不能:(

【问题讨论】:

    标签: php cakephp share linkedin cakephp-2.0


    【解决方案1】:

    发现问题了! Content-Type 必须是 application/json 才能工作!我认为 x-li-format: json 就足够了,但事实并非如此。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多