私の悪い英語を申し訳ありません。私は同じ質問を考えていますが、違うアイデアがあると思っていますが、私の考え方は異なります。私はカール要求を使用してワードプレスでlaravelのURLをコンパイルしていることを私に尋ねている。私が言うことをよりよく理解するために私のコードを見てください。laravel csrf_token wordpressでcurlを使用してURLリクエストを取得すると、一致しません
<html lang="{{ config('app.locale') }}">
<head>
<!-- ImportInWordpressHeaderStart -->
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="csrf-token" content="{{ csrf_token() }}" />
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- ImportInWordpressHeaderEnd -->
</head>
<body> .......
//here is my complete html part ignore it.
<!-- ImportInWordpressFooterScriptStart -->
<script type="text/javascript" src="{{ asset('frontend/js/jquery-2.1.0.min.js') }}"></script>
<script type="text/javascript">
$("#login form").on('submit', function (e){
e.preventDefault();
$.ajax({
type: $(this).attr('method'),
url: $(this).attr('action'),
data: $(this).serialize(),
dataType: "json", ........... // the rest ajax code.
<!-- ImportInWordpressFooterScriptEnd -->
完全に動作するlaravelでは、コードの上部が完全に完成しています。今私はWordPressのテーマのヘッダーとフッターで行っているものを参照してください。
<?php
//Laravel Home url
$url = "http://example.com/home";
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// grab URL and pass it to the browser
$output = curl_exec($ch);
//Regular expression to excerpt the targeted portion
preg_match('/<!-- ImportInWordpressFooterStart -->(.*?)<!--ImportInWordpressFooterEnd -->/s', $output, $footer);
preg_match('/<!-- ImportInWordpressFooterScriptStart -->(.*?)<!-- ImportInWordpressFooterScriptEnd -->/s', $output, $script);
// close curl resource, and free up system resources
curl_close($ch);
?>
<?php echo $footer[0];
wp_footer();
echo $script[0];
?>
は今laravelに私はそれが完全に記録されますログイン時にクリックしたときに私はワードプレスで同じことをしようとすると、それは私に
http://example.com/wordpress
ワードプレスとlaravelがあるトークン不一致エラーを与えます同じドメイン内の両方私はwordpressで同じlaravelヘッダーフッターを再度作成したくありません。どんな良いアイデアをいただければ幸いです。ありがとう
したがって、メインドメインは 'example.com'で、Laravelでは' example.com/wordpress'が1つのwordpressを実行していますか? また、データベースはどのように設定されていますか?両方のアプリが同じユーザー情報を共有していますか?いずれのケースでも解決策があります – codiiv
はい、同じドメインのすべてのもの、そしてlaravelとwordpressの両方のテーブルが単一のデータベースにあります。 –