Brian Logan Brian Logan - 10 months ago 40
PHP Question

LARAVEL - Response from SAME url, showing different results


@lukepolo found out that the number 23842515550750742 randomly always goes to 23842515550750744 in JS. Any ideas why?

I am using Laravel for an API I am creating. I am using Forge to run the servers.

When I pull a URL for the interface in Chrome, Safari, FireFox, etc., it is returning an ID that has been increased by 2. When I pull that SAME url, with the same exact request in Postman, CRUD, Terminal via cURL, etc., it returns the CORRECT response.

Results from Postman:

accountid: 1334372826597482
campaignid: 23842515550750742 <-- CORRECT
client_id: 72
id: 817

Results from Chrome:

campaignid:23842515550750744 <-- INCORRECT

I am using the Facebook Marketing API to save the information locally, so I can run massive queries in a much faster resposne than their API would give me. Here is the code for listing the campaigns with basic information:

$campaigns = FacebookPerformanceOverview::whereIn('client_id', $this->sheet_ids)
->whereIn('accountid', $this->accountIds['facebook'])
->whereIn('campaignid', $this->campaigns)
->whereBetween('date', [$this->start_date, $this->end_date])
$response = [];
foreach ($campaigns AS $campaign) {
$data = FacebookPerformanceOverview::whereIn('client_id', $this->sheet_ids)
->whereIn('accountid', $this->accountIds['facebook'])
->where('campaignid', $campaign->campaignid)
->whereIn('adsetid', $this->adsets)
->whereBetween('date', [$this->start_date, $this->end_date]);
$response[] = array(
'company' => $campaign->company,
'campaign' => FacebookCampaignSettings::where('campaignid', $campaign->campaignid)->first(),
'impressions' => $data->sum('impressions'),
'clicks' => $data->sum('clicks'),
'cost' => $data->sum('cost'),
'reach' => $data->sum('reach'),
'frequency' => $data->avg('frequency'),
'uniqueclicks' => $data->sum('uniqueclicks'),
'actions' => $data->sum('actions'),
'offsiteconversions' => $data->sum('offsiteconversions'),
'leads' => $data->sum('actionsleadgen') + $this->calculateLeads(),
return response()->json($response, 200, [], JSON_NUMERIC_CHECK);

I am unable to give the URL, due to it containing sensitive information, but I am confused as to what is going on. I have cleared cache, different browsers, different computers, etc. Web browsers always return the ID in the network tab incorrectly. Any ideas?

Answer Source