$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>REST api header link href|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

REST api header link href

matteradmin8PV0评论

If I call

curl -I 

In terminal I get the correct response

Link: </>; rel="/"

If I call

$response = wp_remote_head( '' );

The I print_r the response. The Link: I get is

Link: ; rel="/"
Link: ; rel=shortlink

There seems to be the href stripped out of the data, but the semi-colon has been left. This is the reccomemded way from wordpress to assert if REST api is active and if pretty permalinks are selected.

What is the correct way to get the href link from the from a page header?

If I call

curl -I https://example

In terminal I get the correct response

Link: <https://example/wp-json/>; rel="https://api.w/"

If I call

$response = wp_remote_head( 'https://example' );

The I print_r the response. The Link: I get is

Link: ; rel="https://api.w/"
Link: ; rel=shortlink

There seems to be the href stripped out of the data, but the semi-colon has been left. This is the reccomemded way from wordpress to assert if REST api is active and if pretty permalinks are selected.

What is the correct way to get the href link from the from a page header?

Share Improve this question asked Dec 5, 2018 at 6:47 digitalcreative.techdigitalcreative.tech 215 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Turns out it was there all along, but being rendered into an html tag during the output. I ended up using;

echo htmlspecialchars($response);

To get this to be displayed correctly on the page. Although I want to be checking against it in php, which I haven't go to figuring out yet, it is nice to have found it working correctly. It was displayed in the html in the element inspector which I hadn't thought to check ....whooops.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far