相关疑难解决方法(0)

如何使用CURL而不是file_get_contents?

我使用file_get_contents函数来获取和显示我的特定页面上的外部链接.

在我的本地文件中一切正常,但我的服务器不支持该file_get_contents功能,所以我尝试使用以下代码的cURL:

function file_get_contents_curl($url) {
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);

    $data = curl_exec($ch);
    curl_close($ch);

    return $data;
}

 echo file_get_contents_curl('http://google.com');
Run Code Online (Sandbox Code Playgroud)

但它返回一个空白页面.怎么了?

php curl file-get-contents

34
推荐指数
2
解决办法
7万
查看次数

Wordpress插件连接到REST API?

假设我在某个服务器上运行RESTful API,以及一个单独但相关的Wordpress站点.

我希望WP站点上有一些页面显示从REST服务器检索的WP页面上的数据(采用JSON格式),并允许用户查看和/或编辑WP页面上的数据.

例如,假设我有一个返回用户拥有的书籍列表的API作为REST起点.我想显示书籍列表,允许用户点击书籍链接并转到显示书籍详细信息的页面.

然后,如果用户进入"编辑模式",则允许他/她编辑数据并通过REST API将其POST/PUT返回服务器.

有没有WP插件可以让我创建显示和编辑这样的信息的页面?

我希望对于每种类型的实体,我都可以输入一些元数据来指示JSON中的内容,以及如何显示它以供查看或如何为其构建表单(如iPhorms所做的那样).

api rest wordpress plugins json

25
推荐指数
2
解决办法
3万
查看次数

php中的file_get_contents或curl?

在PHP中使用file_get_contentscurl应该使用哪个来发出HTTP请求?

如果file_get_contents能完成这项工作,是否需要使用curl?使用curl似乎需要更多的线条.

例如:

卷曲:

$ch = curl_init('http://www.website.com/myfile.php'); 
curl_setopt($ch, CURLOPT_POST, true); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $content); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
$output = curl_exec ($ch); 
curl_close ($ch); 
Run Code Online (Sandbox Code Playgroud)

的file_get_contents:

$output = file_get_contents('http://www.website.com/myfile.php'.$content); 
Run Code Online (Sandbox Code Playgroud)

php curl file-get-contents

8
推荐指数
3
解决办法
2万
查看次数

如何从 guzzle 请求获取并显示图像

我正在尝试显示来自 guzzle 请求的图像,一切正常,但我无法显示图像。

这是我在尝试获取用户数据时得到的结果

object(GuzzleHttp\Psr7\Response)#427 (6) { ["reasonPhrase":"GuzzleHttp\Psr7\Response":private]=> string(2) "OK" ["statusCode":"GuzzleHttp\Psr7\Response":private]=> int(200) ["headers":"GuzzleHttp\Psr7\Response":private]=> array(14) { ["Server"]=> array(1) { [0]=> string(6) "Cowboy" } ["Connection"]=> array(1) { [0]=> string(10) "keep-alive" } ["X-Powered-By"]=> array(1) { [0]=> string(7) "Express" } ["X-Timestamp"]=> array(1) { [0]=> string(13) "1556374181931" } ["Content-Disposition"]=> array(1) { [0]=> string(51) "attachment; filename =profile_img-1556366764744.jpg" } ["X-Sent"]=> array(1) { [0]=> string(4) "true" } ["Accept-Ranges"]=> array(1) { [0]=> string(5) "bytes" } ["Cache-Control"]=> array(1) { [0]=> string(17) "public, max-age=0" } ["Last-Modified"]=> array(1) { [0]=> string(29) "Sat, …
Run Code Online (Sandbox Code Playgroud)

php ajax laravel guzzle

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

Connectwise REST API 实现

在我的应用程序中,我将使用 connectwise API,但我不知道如何调用它们的 API,例如

  1. API 端点
  2. 如何传递标题
  3. 如何进行身份验证(我有公司 ID、公钥和私钥)
  4. 如何拨打电话并接听回复
  5. 我是 PHP 人

在此先感谢您的帮助!!

api rest

2
推荐指数
1
解决办法
6620
查看次数

标签 统计

php ×3

api ×2

curl ×2

file-get-contents ×2

rest ×2

ajax ×1

guzzle ×1

json ×1

laravel ×1

plugins ×1

wordpress ×1