【发布时间】:2016-07-06 07:02:25
【问题描述】:
我已经从 GitHub 上传了所有“Official PHP SDK for the Content Delivery API”文件和文件夹到我的服务器上名为“Contentful”的文件夹中。
然后我尝试按照 Contentful site 的教程进行操作,但是当然,我无法让它工作,因为我没有使用 Composer。
代码如下:
require_once 'vendor/autoload.php';
// This is the space ID. A space is like a project folder in Contentful terms
$space='developer_bookshelf';
// This is the access token for this space. Normally you get both ID and the token in the Contentful web app
$token='0b7f6x59a0';
// This configures the SDK to access the Delivery API entry with the specified ID from the space defined at the top, using a space-specific access token.
$client = new \Contentful\Delivery\Client($token, $space);
// This retrieves the entry with the specified ID and JSON encodes it
echo json_encode($client->getEntry('5PeGS2SoZGSa4GuiQsigQu'), JSON_PRETTY_PRINT);
在 GitHub 上,我找不到手动安装和初始化 SDK 的说明。
我真的很想在一个项目中使用 Contentful,但是作为一个初级 PHP 开发人员,对 Composer 一无所知,我需要指导。
任何好的灵魂都可以帮助我修改我的代码,以便我可以初始化 SDK 并开始从 Contentful API 检索数据?需要哪些文件?我需要做任何事情来自动加载类吗?这么多的疑问...
我的主人:Pagely。 我的工作区:Codeanywhere。
非常感谢。
【问题讨论】:
-
谢谢你的帮助,伙计。
标签: php composer-php contentful