Добавить
Уведомления

API tutorial for Beginners step by step - 7 - how to consume API with PHP

Question 1: At first you should check ini setting allow_url_fopen, AFAIK this is the only reason why file_get_contents() shouldn't work. Also deprecated safe_mode may cause this. Oh, based on your comment, you have to add http:// to URL when using with file system functions, it's a wrapper that tells php that you need to use http request, without it function thinks you require to open ./google.com (the same as google.txt). Question 2: Yes, you can build almost any cURL request with sockets. My personal opinion is that you should stick with cURL because: timeout settings handles all possible HTTP states easy and detailed configuration (there is no need for detailed knowledge of HTTP headers)

Иконка канала Кодерские решения
8 подписчиков
12+
16 просмотров
2 года назад
12+
16 просмотров
2 года назад

Question 1: At first you should check ini setting allow_url_fopen, AFAIK this is the only reason why file_get_contents() shouldn't work. Also deprecated safe_mode may cause this. Oh, based on your comment, you have to add http:// to URL when using with file system functions, it's a wrapper that tells php that you need to use http request, without it function thinks you require to open ./google.com (the same as google.txt). Question 2: Yes, you can build almost any cURL request with sockets. My personal opinion is that you should stick with cURL because: timeout settings handles all possible HTTP states easy and detailed configuration (there is no need for detailed knowledge of HTTP headers)

, чтобы оставлять комментарии