git -C '/home/opc/rocketa.git' show df26125 -- app/Http/Controllers/Media/Ad.phpcommit df26125a6073a9e4567aa83b75d56071daa471bd
Author: Satoshi Ujihara <satoshi_ujihara@fivegate.jp>
Date: Wed Nov 19 17:33:59 2025 +0900
翻訳文字追加
テストセンター機能修正(実際のMMPのポストバックに近い形式でテストできるよう修正+デザインの修正)
diff --git a/app/Http/Controllers/Media/Ad.php b/app/Http/Controllers/Media/Ad.php
index a6b0c99..f36ce24 100644
--- a/app/Http/Controllers/Media/Ad.php
+++ b/app/Http/Controllers/Media/Ad.php
@@ -16,8 +16,10 @@ use App\Models\La\AdRewardDatas;
use App\Models\La\AdRewardGroupDatas;
use App\Models\La\AdJoinMediaDatas;
use App\Models\La\AdMaterialDatas;
+use App\Models\La\PostbackSamples;
use App\Models\Api\ApiAdJoinMediaDatas;
use App\Models\Api\ApiClickRecordsTest;
+
use Illuminate\Foundation\Console\Presets\Vue;
use Illuminate\Support\Facades\Artisan;
@@ -220,35 +222,57 @@ class Ad extends Controller
public function clickRecordTest($click_records_test_id)
{
try {
- $click_records_test = ApiClickRecordsTest::select()
- ->where('id', $click_records_test_id)->first();
- $client = new Client();
- $send_query= [];
- $send_query['ad_id']= $click_records_test->master_ad_id;
- $send_query['sid']= $click_records_test->sid;
- $send_query['client_id']= $click_records_test->client_id;
- $send_query['event_name']= "install";
- $response = $client->get("https://api.rocket-a.com/service/test2", [
- 'query' => $send_query,
- 'http_errors' => false,
- ]);
- $response_result = $response->getStatusCode();
-
- if ($response_result == 200) {
- $body = $response->getBody()->getContents();
- // JSONを連想配列に変換
- $data = json_decode($body, true);
- Artisan::call('get_result_data_tests', ['insert_id' => $data['insert_id']]);
- }
+ $click_records_test = ApiClickRecordsTest::select()
+ ->where('id', $click_records_test_id)->first();
+ $ad_data = AdDatas::select()->where('id', $click_records_test->master_ad_id)->first();
+ $postback_sample = PostbackSamples::select()->where('result_method', $ad_data->result_method)->first();
+ $url = "https://api.rocket-a.com/service/test2?" . $postback_sample->url;
+ $query= [];
+ $query['sid']= $click_records_test->sid;
+ $query['ad_id']= $click_records_test->master_ad_id;
+ $query['media_id']= $click_records_test->media_id;
+ $query['client_id']= $click_records_test->client_id;
+ $query['banner_id']= $click_records_test->banner_id;
+ $query['event_name']= "install";
+ $replaced_url = preg_replace_callback('/\{([\w\.]+)\}/', function ($matches) use ($query) {
+ $key = $matches[1];
+ return isset($query[$key]) ? $query[$key] : ''; // 未設定は空文字
+ }, $url );
+ $url = explode('?', $replaced_url);
+
+ $path = $url[0];
+ if (isset($url[1])) {
+ parse_str($url[1], $send_query);
+ }
+
+
+ $client = new Client();
+ $response = $client->get($path, [
+ 'query' => $send_query,
+ 'http_errors' => false,
+ ]);
+ $response_result = $response->getStatusCode();
+
+ if ($response_result == 200) {
+ $body = $response->getBody()->getContents();
+ // JSONを連想配列に変換
+ $data = json_decode($body, true);
+ if(!isset($data['insert_id'])) {
+ var_dump($data);
+ exit;
+ } else {
+ Artisan::call('get_result_data_tests', ['insert_id' => $data['insert_id']]);
+ }
+ }
} catch (RequestException $e) {
- if ($e->hasResponse()) {
- echo "HTTP Error: " . $e->getResponse()->getStatusCode() . "\n";
- echo "Response body: " . $e->getResponse()->getBody();
- } else {
- echo "Request failed before getting a response\n";
- echo $e->getMessage();
- }
-}
+ if ($e->hasResponse()) {
+ echo "HTTP Error: " . $e->getResponse()->getStatusCode() . "\n";
+ echo "Response body: " . $e->getResponse()->getBody();
+ } else {
+ echo "Request failed before getting a response\n";
+ echo $e->getMessage();
+ }
+ }
return redirect(url()->previous());
}