回答編集履歴
2
json用header追加
answer
CHANGED
@@ -21,6 +21,7 @@
|
|
21
21
|
$output['headerImg'] = 'http://hogehoge.com/headerImg.jpg';
|
22
22
|
$output['topLink'] = 'http://hogehoge.com/top.php';
|
23
23
|
|
24
|
+
header('content-type: application/json; charset=utf-8');
|
24
25
|
echo json_encode($output);
|
25
26
|
|
26
27
|
```
|
1
追記
answer
CHANGED
@@ -8,4 +8,32 @@
|
|
8
8
|
|
9
9
|
```
|
10
10
|
|
11
|
-
としてください
|
11
|
+
としてください
|
12
|
+
|
13
|
+
2019-04-02 13:23追記
|
14
|
+
PHPの中身は共有できません。(serializeなど方法はあるけどセキュリティ的によろしくない)
|
15
|
+
なのでこの場合API化してJSON形式でやり取りするのがベストでしょう。
|
16
|
+
その場合
|
17
|
+
|
18
|
+
```php
|
19
|
+
<?php
|
20
|
+
//送る方
|
21
|
+
$output['headerImg'] = 'http://hogehoge.com/headerImg.jpg';
|
22
|
+
$output['topLink'] = 'http://hogehoge.com/top.php';
|
23
|
+
|
24
|
+
echo json_encode($output);
|
25
|
+
|
26
|
+
```
|
27
|
+
|
28
|
+
とし
|
29
|
+
|
30
|
+
```php
|
31
|
+
<?php
|
32
|
+
//受ける方
|
33
|
+
|
34
|
+
$apiResponse = file_get_contents('http://hogehoge.com/imgsrc.php');
|
35
|
+
$input = json_decode($apiResponse,true);
|
36
|
+
echo $input['topLink'];
|
37
|
+
```
|
38
|
+
|
39
|
+
で試してみてください。
|