简体   繁体   English

如何使用php从Dreamfactory中显示文件文件夹中的图像

[英]How to display images in files folder from dreamfactory using php

I have uploaded images files in folder of Dreamfactory 我已将图片文件上传到Dreamfactory的文件夹中

<img src="https://motodev.spotya.online/api/v2/files/Posts/posts_1508937621_Tulips.jpg">

Error Displayed, 显示错误

{"error":{"code":400,"context":null,"message":"No session token (JWT) or API Key detected in request.."} {“错误”:{“代码”:400,“上下文”:null,“消息”:“在请求中未检测到会话令牌(JWT)或API密钥。”}

It looks like your files endpoint in dreamfactory is secured. 看来您在dreamfactory中的files终结点已得到保护。 You need to provide API key or JWT token to access the files inside this directory. 您需要提供API密钥或JWT令牌才能访问此目录中的文件。 Another way is to add guest access to your files endpoint, as described here . 另一种方法是来宾访问添加到您的files的端点,描述在这里

You need to generate url like https://example.org/api/v2/files/image.jpg?api_key=<your api key> . 您需要生成类似https://example.org/api/v2/files/image.jpg?api_key=<your api key>网址。 For example: 例如:

<?php

// your guest API key
$apiKey = 'your api key should be here';
// your file URL
$baseUrl = 'https://example.org/api/v2/files/image.jpg';
// resulted URL
$finalUrl = $baseUrl . http_build_query(['api_key' => $apiKey]);

?>

<img src="<?= $finalUrl ?>">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM