【发布时间】:2013-12-19 01:26:51
【问题描述】:
我正在尝试使用 OAuth 2.0、PHP 和 cURL 将照片发布到微博服务 Alpha.App.net,我需要为此使用 JSON oEmbed 规范。
以下是我尝试过的,但它会导致错误响应:
“错误请求:'annotations': 必须是一个列表”
function sendMessage()
{
$postData = array(
'text' => "test",
'annotations' => array('type' => 'net.app.core.oembed',
'version' => '1.0',
'type' => 'photo',
'width' => 240,
'height' => 160,
'title' => 'ZB8T0193',
'url' => 'http://farm4.static.flickr.com/3123/2341623661_7c99f48bbf_m.jpg',
'author_name' => 'Bees',
'author_url' => 'http://www.flickr.com/photos/bees/',
'provider_name' => 'Flickr',
'provider_url' => 'http://www.flickr.com/',
'embeddable_url' => 'http://www.flickr.com/photos/bees/2341623661/')
);
$ch = curl_init('https://alpha-api.app.net/stream/0/posts');
curl_setopt_array($ch, array(
CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => array('Authorization: Bearer '.'0123456789',
'Content-Type: application/json'
),
CURLOPT_POSTFIELDS => json_encode($postData)
));
这是来自docs 的原始 JSON:
{
"type": "net.app.core.oembed",
"value": {
"version": "1.0",
"type": "photo",
"width": 240,
"height": 160,
"title": "ZB8T0193",
"url": "http://farm4.static.flickr.com/3123/2341623661_7c99f48bbf_m.jpg",
"author_name": "Bees",
"author_url": "http://www.flickr.com/photos/bees/",
"provider_name": "Flickr",
"provider_url": "http://www.flickr.com/",
"embeddable_url": "http://www.flickr.com/photos/bees/2341623661/"
}
}
我需要更改哪些内容才能使其成为列表?
【问题讨论】: