小编Erh*_*han的帖子

为 Apple-news 创建文章的 PHP 代码

更新:下面的代码对我有用。希望它可以帮助某人找出他们的问题。

在遇到几个错误后,它有助于返回并查看 Apple News Developer 站点上所有可能的错误代码。查看代码中的特定错误编号并确定它可能有什么问题。

按照 Apple News Developer 网站上的示例进行操作。尽管它们含糊不清,但它们确实包含重要信息!

//set the timezone
date_default_timezone_set('UTC');

//get json to be sent

$raw = file_get_contents('article.json');
$eol = "\r\n";
$data = '';
$bound= '535e329ca936f79a19ac9a251f7d48f7';

$data='--'.$bound.$eol.
"Content-Type: application/json" . $eol.
"Content-Disposition: form-data; name=metadata" . $eol. $eol.
'{
"data": {
    "isCandidateToBeFeatured": "false",
    "isSponsored": false,
    "isPreview": true     
}
}' .$eol.
'--'.$bound.$eol.
"Content-Type: application/json" . $eol.
"Content-Disposition: form-data; filename=article.json; name=article.json".$eol.$eol.
$raw.$eol.
'--'.$bound.'--'.$eol.$eol;

//set variables
$http_method = 'POST';
$date = gmdate('Y-m-d\TH:i:s\Z');
$key = 'xxx';
$url = 'https://news-api.apple.com/channels/xxx/articles';
$secret …
Run Code Online (Sandbox Code Playgroud)

php curl apple-news

5
推荐指数
1
解决办法
509
查看次数

标签 统计

apple-news ×1

curl ×1

php ×1