


file_get_contents cannot obtain web content, filegetcontents_PHP tutorial
file_get_contents cannot obtain web content. filegetcontents
In the process of signature verification, the server often needs to obtain a user's information from the channel server. There are generally two methods, curl and file_get_contents.
Under normal circumstances, there will be no problem if you use it like this.
<span> 1</span> <span>public</span> <span>function</span> OauthPostExecuteNew(<span>$sign</span>,<span>$requestString</span>,<span>$request_serverUrl</span><span>){ </span><span> 2</span> <span>$opt</span> = <span>array</span>("http"=><span>array</span><span>( </span><span> 3</span> "method"=>"GET", <span> 4</span> "header"=><span>array</span>("param:".<span>$requestString</span>,"oauthsignature:".<span>$sign</span>), <span> 5</span> "request_fulluri"=><span>true</span> <span> 6</span> <span> ) </span><span> 7</span> <span> ); </span><span> 8</span> <span> 9</span> <span>$context</span> = <span>stream_context_create</span>(<span>$opt</span><span>); </span><span>10</span> <span>$res</span>=<span>file_get_contents</span>(<span>$request_serverUrl</span>, <span>false</span>, <span>$context</span><span>); </span><span>11</span> <span>12</span> <span>return</span> <span>$res</span><span>; </span><span>13</span> }
However, since our server connects to the external network through a proxy, you need to bring the proxy parameter when using stream_context_create to access the channel server.
So in the above code, add the "proxy"=>$proxy field to the $opt array. After adding it, I found that file_get_contents still cannot be verified normally.
I was puzzled, so I went to the official website to check file_get_contents and found that there was no explanation about proxy. Then I searched for stream_context_create and found this official explanation
<p><code class="parameter">params</code></p> <p class="para">必须是 <em>$arr['parameter'] = $value</em> 格式的关联数组。 请参考 context parameters 里的标准资源流参数列表。</p>
Then we enter context_parameters to view the parameter configuration. Because we are using HTTP, check the HTTP context
View proxy-related
<p class="para"><code class="parameter">proxy</code> <span class="type">string</span></p> <p class="para">URI 指定的代理服务器的地址。(e.g. <em>tcp://proxy.example.com:5100</em>).</p> <p class="para"><code class="parameter">request_fulluri</code> <span class="type">boolean</span></p> <p class="para">当设置为 <code>TRUE</code> 时,在构建请求时将使用整个 URI 。(i.e. <em>GET http://www.example.com/path/to/file.html HTTP/1.0</em>)。 虽然这是一个非标准的请求格式,但某些代理服务器需要它。</p> <p class="para">默认值是 <code>FALSE</code>.</p>
I found that only proxy was configured, but request_fulluri was not configured, so I added request_fulluri=true and the verification passed.
Note: When using the proxy parameter, you need to change http to tcp. I don’t know the specific reason. I'll update here when I find out.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to send web pages to the desktop as a shortcut in Edge browser? Many of our users want to display frequently used web pages on the desktop as shortcuts for the convenience of directly opening access pages, but they don’t know how to do it. In response to this problem, the editor of this issue will share the solution with the majority of users. , let’s take a look at the content shared in today’s software tutorial. The shortcut method of sending web pages to the desktop in Edge browser: 1. Open the software and click the "..." button on the page. 2. Select "Install this site as an application" in "Application" from the drop-down menu option. 3. Finally, click it in the pop-up window

To learn more about open source, please visit: 51CTO Hongmeng Developer Community https://ost.51cto.com Running environment DAYU200:4.0.10.16SDK: 4.0.10.15IDE: 4.0.600 1. To create an application, click File- >newFile->CreateProgect. Select template: [OpenHarmony] EmptyAbility: Fill in the project name, shici, application package name com.nut.shici, and application storage location XXX (no Chinese, special characters, or spaces). CompileSDK10, Model: Stage. Device

The browser cannot open the web page but the network is normal. There are many possible reasons. When this problem occurs, we need to investigate step by step to determine the specific cause and solve the problem. First, determine whether the webpage cannot be opened is limited to a specific browser or whether all browsers cannot open the webpage. If only one browser cannot open the web page, you can try to use other browsers, such as Google Chrome, Firefox, etc., for testing. If other browsers are able to open the page correctly, the problem is most likely with that specific browser, possibly

How to change the page that opens the Microsoft Edge browser to 360 navigation? It is actually very simple, so now I will share with you the method of changing the page that opens the Microsoft Edge browser to 360 navigation. Friends in need can take a look. I hope Can help everyone. Open the Microsoft Edge browser. We see a page like the one below. Click the three-dot icon in the upper right corner. Click "Settings." Click "On startup" in the left column of the settings page. Click on the three points shown in the picture in the right column (do not click "Open New Tab"), then click Edit and change the URL to "0" (or other meaningless numbers). Then click "Save". Next, select "

Google Authenticator is a tool used to protect the security of user accounts, and its key is important information used to generate dynamic verification codes. If you forget the key of Google Authenticator and can only verify it through the security code, then the editor of this website will bring you a detailed introduction on where to get the Google security code. I hope it can help you. If you want to know more Users please continue reading below! First open the phone settings and enter the settings page. Scroll down the page and find Google. Go to the Google page and click on Google Account. Enter the account page and click View under the verification code. Enter your password or use your fingerprint to verify your identity. Obtain a Google security code and use the security code to verify your Google identity.

How to solve the problem of web pages not opening With the rapid development of the Internet, people increasingly rely on the Internet to obtain information, communicate and entertain. However, sometimes we encounter the problem that the web page cannot be opened, which brings us a lot of trouble. This article will introduce you to some common methods to help solve the problem of web pages not opening. First, we need to determine why the web page cannot be opened. Possible reasons include network problems, server problems, browser settings problems, etc. Here are some solutions: Check network connection: First, we need

Some netizens found that when they opened the browser web page, the pictures on the web page could not be loaded for a long time. What happened? I checked that the network is normal, so where is the problem? The editor below will introduce to you six solutions to the problem that web page images cannot be loaded. Web page images cannot be loaded: 1. Internet speed problem The web page cannot display images. It may be because the computer's Internet speed is relatively slow and there are more softwares opened on the computer. And the images we access are relatively large, which may be due to loading timeout. As a result, the picture cannot be displayed. You can turn off the software that consumes more network speed. You can go to the task manager to check. 2. Too many visitors. If the webpage cannot display pictures, it may be because the webpages we visited were visited at the same time.

If you are an IT administrator or technology expert, you must be aware of the importance of automation. Especially for Windows users, Microsoft PowerShell is one of the best automation tools. Microsoft offers a variety of tools for your automation needs, without the need to install third-party applications. This guide will detail how to leverage PowerShell to automate tasks. What is a PowerShell script? If you have experience using PowerShell, you may have used commands to configure your operating system. A script is a collection of these commands in a .ps1 file. .ps1 files contain scripts executed by PowerShell, such as basic Get-Help
