php setcookie isn't setting the cookie [duplicate] - php

This question already has answers here:
Cookies on localhost with explicit domain
(24 answers)
Closed 5 years ago.
I have an application that uses saml authentication and passes the response back via a cookie to the return URL the SP provides. The php code looks like this
setcookie('auth', $cred, time() + 30, parse_url($location, PHP_URL_HOST));
error_log($_COOKIE['auth']);
header('Location: ' . $location, true, 303);
die();
The redirect works fine but the cookie is not set. This is confirmed both in php as shown above, and in my application using document.cookies
I've exported the HAR to view the request and it actually looks like the cookie is being set, but it's still not accessible via document.cookie. The way it is supposed to work is that the application changes the window.location to the php file that authenticates, sets the cookie and redirects to the return parameter. Judging by the fact that the request is sent with the cookie, I'd guess that it is being set, but I can't seem to access it.
{
"startedDateTime": "2017-10-27T18:05:36.538Z",
"time": 271.7059999888301,
"request": {
"method": "GET",
"url": "https://supportworkslab.sw.test/sw/selfservice/sso/saml_auth.php?wssinstance=selfservice&returnto=http%3A%2F%2Flocalhost%2Fsw%2Fselfservice",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Pragma",
"value": "no-cache"
},
{
"name": "Accept-Encoding",
"value": "gzip, deflate, br"
},
{
"name": "Host",
"value": "supportworkslab.sw.test"
},
{
"name": "Accept-Language",
"value": "en-US,en;q=0.9"
},
{
"name": "Upgrade-Insecure-Requests",
"value": "1"
},
{
"name": "User-Agent",
"value": "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36"
},
{
"name": "Accept",
"value": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"
},
{
"name": "Referer",
"value": "http://localhost/sw/selfservice/"
},
{
"name": "Cookie",
"value": "auth=eyJzdWNjZXNzIjoiQXV0aGVudGljYXRpb24gc3VjY2VzcyEiLCJjdXN0aWQiOiJhbGFuYyIsInNlc3Npb25JZCI6IjU5ZjM2MGRjLTBhOTI5NWFlLTQxYzEiLCJ3ZWJGbGFncyI6IjIxNDc0ODk1NTEiLCJjYWxsQ2xhc3MiOiJJbmNpZGVudCIsImFzc2lnbkdyb3VwIjoiU1VQUE9SVCIsImFzc2lnbkFuYWx5c3QiOiIifQ%3D%3D; SimpleSAMLAuthToken=_04a2be772f96fad7c5e2452846c05df5cbd570305e; SimpleSAML=62d6b2ebea7f66b0360a328dcb4f77a7; PHPSESSID=k9hpb09i3omt43bv7gireeuid0"
},
{
"name": "Connection",
"value": "keep-alive"
},
{
"name": "Cache-Control",
"value": "no-cache"
}
],
"queryString": [
{
"name": "wssinstance",
"value": "selfservice"
},
{
"name": "returnto",
"value": "http%3A%2F%2Flocalhost%2Fsw%2Fselfservice"
}
],
"cookies": [
{
"name": "auth",
"value": "eyJzdWNjZXNzIjoiQXV0aGVudGljYXRpb24gc3VjY2VzcyEiLCJjdXN0aWQiOiJhbGFuYyIsInNlc3Npb25JZCI6IjU5ZjM2MGRjLTBhOTI5NWFlLTQxYzEiLCJ3ZWJGbGFncyI6IjIxNDc0ODk1NTEiLCJjYWxsQ2xhc3MiOiJJbmNpZGVudCIsImFzc2lnbkdyb3VwIjoiU1VQUE9SVCIsImFzc2lnbkFuYWx5c3QiOiIifQ%3D%3D",
"expires": null,
"httpOnly": false,
"secure": false
},
{
"name": "SimpleSAMLAuthToken",
"value": "_04a2be772f96fad7c5e2452846c05df5cbd570305e",
"expires": null,
"httpOnly": false,
"secure": false
},
{
"name": "SimpleSAML",
"value": "62d6b2ebea7f66b0360a328dcb4f77a7",
"expires": null,
"httpOnly": false,
"secure": false
},
{
"name": "PHPSESSID",
"value": "k9hpb09i3omt43bv7gireeuid0",
"expires": null,
"httpOnly": false,
"secure": false
}
],
"headersSize": 996,
"bodySize": 0
},
"response": {
"status": 303,
"statusText": "See Other",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Pragma",
"value": "no-cache"
},
{
"name": "Date",
"value": "Fri, 27 Oct 2017 18:05:36 GMT"
},
{
"name": "Server",
"value": "Apache"
},
{
"name": "Content-Type",
"value": "text/html"
},
{
"name": "Location",
"value": "http://localhost/sw/selfservice"
},
{
"name": "Set-Cookie",
"value": "SimpleSAML=62d6b2ebea7f66b0360a328dcb4f77a7; path=/; HttpOnly"
},
{
"name": "Set-Cookie",
"value": "PHPSESSID=k9hpb09i3omt43bv7gireeuid0; path=/; HttpOnly"
},
{
"name": "Set-Cookie",
"value": "auth=eyJzdWNjZXNzIjoiQXV0aGVudGljYXRpb24gc3VjY2VzcyEiLCJjdXN0aWQiOiJhbGFuYyIsInNlc3Npb25JZCI6IjU5ZjM3NTcwLTBhZTJmNzAzLTNmMTIiLCJ3ZWJGbGFncyI6IjIxNDc0ODk1NTEiLCJjYWxsQ2xhc3MiOiJJbmNpZGVudCIsImFzc2lnbkdyb3VwIjoiU1VQUE9SVCIsImFzc2lnbkFuYWx5c3QiOiIifQ%3D%3D; expires=Fri, 27-Oct-2017 18:06:36 GMT; Max-Age=60; domain=localhost"
},
{
"name": "Cache-Control",
"value": "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
},
{
"name": "Content-Security-Policy",
"value": "default-src 'self' *.sw.test; frame-src *.twitter.com; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.twitter.com *.twimg.com; style-src 'self' 'unsafe-inline' *.twitter.com *.twimg.com; img-src 'self' data: *.twimg.com *.twitter.com;"
},
{
"name": "Connection",
"value": "Keep-Alive"
},
{
"name": "Keep-Alive",
"value": "timeout=5, max=100"
},
{
"name": "Content-Length",
"value": "0"
},
{
"name": "Expires",
"value": "Thu, 19 Nov 1981 08:52:00 GMT"
}
],
"cookies": [
{
"name": "SimpleSAML",
"value": "62d6b2ebea7f66b0360a328dcb4f77a7",
"path": "/",
"expires": null,
"httpOnly": true,
"secure": false
},
{
"name": "PHPSESSID",
"value": "k9hpb09i3omt43bv7gireeuid0",
"path": "/",
"expires": null,
"httpOnly": true,
"secure": false
},
{
"name": "auth",
"value": "eyJzdWNjZXNzIjoiQXV0aGVudGljYXRpb24gc3VjY2VzcyEiLCJjdXN0aWQiOiJhbGFuYyIsInNlc3Npb25JZCI6IjU5ZjM3NTcwLTBhZTJmNzAzLTNmMTIiLCJ3ZWJGbGFncyI6IjIxNDc0ODk1NTEiLCJjYWxsQ2xhc3MiOiJJbmNpZGVudCIsImFzc2lnbkdyb3VwIjoiU1VQUE9SVCIsImFzc2lnbkFuYWx5c3QiOiIifQ%3D%3D",
"domain": "localhost",
"expires": "2017-10-27T18:06:36.254Z",
"httpOnly": false,
"secure": false
}
],
"content": {
"size": 0,
"mimeType": "text/html",
"compression": 0
},
"redirectURL": "http://localhost/sw/selfservice",
"headersSize": 1104,
"bodySize": 0,
"_transferSize": 1104
},

Make sure your $cred var is defined and a valid string
Make sure the result of the parse_url() function on $location returns a valid string....it has to match exactly the domain you work on so watch out for subdomain issues.
Obviously make sure you check before it expires....60 seconds.

Related

Wordpress 401 error: rest_forbidden. Sorry, you are not allowed to make proxied oEmbed requests

I'm getting 401 error on the following URL call on my Wordpress hosted on Windows IIS server:
https://example.com/wp-json/oembed/1.0/proxy?url=https://example.com/wp-content/uploads/img.jpg
{
"code": "rest_forbidden",
"message": "Sorry, you are not allowed to make proxied oEmbed requests.",
"data": {
"status": 401
}
}
The above URL is called by the Elementor gallery widget when I want to set an external image for it.
Although, the following URL is working on my Wordpress site:
https://example.com/wp-json/oembed/1.0?url=https://example.com/wp-content/uploads/img.jpg
{
"namespace": "oembed\/1.0",
"routes": {
"\/oembed\/1.0": {
"namespace": "oembed\/1.0",
"methods": ["GET"],
"endpoints": [{
"methods": ["GET"],
"args": {
"namespace": {
"default": "oembed\/1.0",
"required": false
},
"context": {
"default": "view",
"required": false
}
}
}
],
"_links": {
"self": [{
"href": "https:\/\/example.com\/wp-json\/oembed\/1.0"
}
]
}
},
"\/oembed\/1.0\/embed": {
"namespace": "oembed\/1.0",
"methods": ["GET"],
"endpoints": [{
"methods": ["GET"],
"args": {
"url": {
"description": "The URL of the resource for which to fetch oEmbed data.",
"type": "string",
"format": "uri",
"required": true
},
"format": {
"default": "json",
"required": false
},
"maxwidth": {
"default": 600,
"required": false
}
}
}
],
"_links": {
"self": [{
"href": "https:\/\/example.com\/wp-json\/oembed\/1.0\/embed"
}
]
}
},
"\/oembed\/1.0\/proxy": {
"namespace": "oembed\/1.0",
"methods": ["GET"],
"endpoints": [{
"methods": ["GET"],
"args": {
"url": {
"description": "The URL of the resource for which to fetch oEmbed data.",
"type": "string",
"format": "uri",
"required": true
},
"format": {
"description": "The oEmbed format to use.",
"type": "string",
"default": "json",
"enum": ["json", "xml"],
"required": false
},
"maxwidth": {
"description": "The maximum width of the embed frame in pixels.",
"type": "integer",
"default": 600,
"required": false
},
"maxheight": {
"description": "The maximum height of the embed frame in pixels.",
"type": "integer",
"required": false
},
"discover": {
"description": "Whether to perform an oEmbed discovery request for unsanctioned providers.",
"type": "boolean",
"default": true,
"required": false
}
}
}
],
"_links": {
"self": [{
"href": "https:\/\/example.com\/wp-json\/oembed\/1.0\/proxy"
}
]
}
}
},
"_links": {
"up": [{
"href": "https:\/\/example.com\/wp-json\/"
}
]
}
}
PHP: 7.4.16
Wordpress: 5.6.2
Windows Server: 2019

A Non Numeric Value Encountered When Trying To Return Data URL PHP

I am currently trying to present a screen shot of a webpage after a user inputs a custom url. I am using google api pagespeedonline to grab the contents of the page as well as fetch the actual data url but when i go to return it on my backend I cant get it to successfuly return just the data url. My current code for doing so is:
public function web_preview(Request $request)
{
try {
$url = $this->check_url($request->input('url'));
} catch (\Exception $e) {
return $this->badRequestResponse($e->getMessage());
}
$info = $this->curl_file_info($url, $this::$ACCEPTABLE_HTML);
if (!$this->is_textual($info))
return $this->clientErrorResponse("Nontextual web asset");
if ($info["http_code"] !== 200)
return $this->clientErrorResponse("URL returned ",$info["http_code"]);
try {
$curl_init = curl_init(
"https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=" + $url + "&key=AIzaSyCxGGWVSSY3fau3cPekSaY765XKRKHerNY&screenshot=true");
curl_setopt($curl_init, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl_init);
curl_close($curl_init);
//call Google PageSpeed Insights API
//decode json data
$googlepsdata = json_decode($response);
//screenshot data
$snap = $googlepsdata['screenshot-thumbnails']['details']['data'];
} catch(\Exception $e) {
return $this->internalServerError($e->getMessage());
}
// $img = Image::make($snap);
return $snap;
}
and the curl_init should return this:
{
"captchaResult": "CAPTCHA_NOT_NEEDED",
"kind": "pagespeedonline#result",
"id": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs",
"loadingExperience": {
"id": "https://developer.mozilla.org",
"metrics": {
"CUMULATIVE_LAYOUT_SHIFT_SCORE": {
"percentile": 0,
"distributions": [
{
"min": 0,
"max": 10,
"proportion": 0.97998381341452667
},
{
"min": 10,
"max": 25,
"proportion": 0.01036026216807024
},
{
"min": 25,
"proportion": 0.00965592441740298
}
],
"category": "FAST"
},
"LARGEST_CONTENTFUL_PAINT_MS": {
"percentile": 1415,
"distributions": [
{
"min": 0,
"max": 2500,
"proportion": 0.92849265950201776
},
{
"min": 2500,
"max": 4000,
"proportion": 0.046497587955101477
},
{
"min": 4000,
"proportion": 0.025009752542881025
}
],
"category": "FAST"
},
"FIRST_INPUT_DELAY_MS": {
"percentile": 3,
"distributions": [
{
"min": 0,
"max": 100,
"proportion": 0.99082487343845982
},
{
"min": 100,
"max": 300,
"proportion": 0.005724879537811014
},
{
"min": 300,
"proportion": 0.0034502470237293141
}
],
"category": "FAST"
},
"FIRST_CONTENTFUL_PAINT_MS": {
"percentile": 1386,
"distributions": [
{
"min": 0,
"max": 1000,
"proportion": 0.55192771567034826
},
{
"min": 1000,
"max": 3000,
"proportion": 0.4031506848279558
},
{
"min": 3000,
"proportion": 0.044921599501695914
}
],
"category": "AVERAGE"
}
},
"overall_category": "AVERAGE",
"initial_url": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs",
"origin_fallback": true
},
"originLoadingExperience": {
"id": "https://developer.mozilla.org",
"metrics": {
"CUMULATIVE_LAYOUT_SHIFT_SCORE": {
"percentile": 0,
"distributions": [
{
"min": 0,
"max": 10,
"proportion": 0.97998381341452667
},
{
"min": 10,
"max": 25,
"proportion": 0.01036026216807024
},
{
"min": 25,
"proportion": 0.00965592441740298
}
],
"category": "FAST"
},
"LARGEST_CONTENTFUL_PAINT_MS": {
"percentile": 1415,
"distributions": [
{
"min": 0,
"max": 2500,
"proportion": 0.92849265950201776
},
{
"min": 2500,
"max": 4000,
"proportion": 0.046497587955101477
},
{
"min": 4000,
"proportion": 0.025009752542881025
}
],
"category": "FAST"
},
"FIRST_INPUT_DELAY_MS": {
"percentile": 3,
"distributions": [
{
"min": 0,
"max": 100,
"proportion": 0.99082487343845982
},
{
"min": 100,
"max": 300,
"proportion": 0.005724879537811014
},
{
"min": 300,
"proportion": 0.0034502470237293141
}
],
"category": "FAST"
},
"FIRST_CONTENTFUL_PAINT_MS": {
"percentile": 1386,
"distributions": [
{
"min": 0,
"max": 1000,
"proportion": 0.55192771567034826
},
{
"min": 1000,
"max": 3000,
"proportion": 0.4031506848279558
},
{
"min": 3000,
"proportion": 0.044921599501695914
}
],
"category": "AVERAGE"
}
},
"overall_category": "AVERAGE",
"initial_url": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs"
},
"lighthouseResult": {
"requestedUrl": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs",
"finalUrl": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs",
"lighthouseVersion": "6.1.0",
"userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/83.0.4103.93 Safari/537.36",
"fetchTime": "2020-08-03T16:07:01.225Z",
"environment": {
"networkUserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4143.7 Safari/537.36 Chrome-Lighthouse",
"hostUserAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/83.0.4103.93 Safari/537.36",
"benchmarkIndex": 674
},
"runWarnings": [],
"configSettings": {
"emulatedFormFactor": "desktop",
"locale": "en-US",
"onlyCategories": [
"performance"
],
"channel": "lr"
},
"audits": {
"critical-request-chains": {
"id": "critical-request-chains",
"title": "Avoid chaining critical requests",
"description": "The Critical Request Chains below show you what resources are loaded with a high priority. Consider reducing the length of chains, reducing the download size of resources, or deferring the download of unnecessary resources to improve page load. [Learn more](https://web.dev/critical-request-chains/).",
"score": null,
"scoreDisplayMode": "informative",
"displayValue": "8 chains found",
"details": {
"type": "criticalrequestchain",
"chains": {
"A5325AC8B1B236F134BF51AA757298E3": {
"children": {
"26.14": {
"request": {
"url": "https://developer.mozilla.org/static/build/styles/l10n-survey.0eeb824ed1eb.css",
"responseReceivedTime": 463937.629765,
"startTime": 463937.613606,
"transferSize": 1436,
"endTime": 463937.629767
}
},
"26.5": {
"request": {
"transferSize": 1570,
"endTime": 463937.662484,
"url": "https://developer.mozilla.org/static/build/styles/auth-modal.be43f0f58a73.css",
"responseReceivedTime": 463937.662481,
"startTime": 463937.611824
}
},
"26.4": {
"request": {
"endTime": 463937.630225,
"startTime": 463937.611595,
"transferSize": 2284,
"responseReceivedTime": 463937.630223,
"url": "https://developer.mozilla.org/static/build/styles/react-header.78d662924939.css"
}
},
"26.12": {
"request": {
"endTime": 463937.634264,
"url": "https://developer.mozilla.org/static/build/styles/banners.e6cd46767c2e.css",
"responseReceivedTime": 463937.63426200004,
"startTime": 463937.613176,
"transferSize": 1376
}
},
"26.8": {
"request": {
"transferSize": 1829,
"startTime": 463937.612959,
"endTime": 463937.662893,
"responseReceivedTime": 463937.662891,
"url": "https://developer.mozilla.org/static/build/styles/prism.a6f275e5032b.css"
}
},
"26.6": {
"request": {
"endTime": 463937.650866,
"url": "https://developer.mozilla.org/static/build/styles/react-mdn.4e0ead71927e.css",
"responseReceivedTime": 463937.65086299996,
"startTime": 463937.612255,
"transferSize": 35533
}
},
"26.13": {
"request": {
"startTime": 463937.613339,
"endTime": 463937.629323,
"transferSize": 1508,
"url": "https://developer.mozilla.org/static/build/styles/mdn-subscriptions.dbb82432d74c.css",
"responseReceivedTime": 463937.62931999995
}
},
"26.7": {
"request": {
"transferSize": 1557,
"startTime": 463937.61266,
"responseReceivedTime": 463937.63605599996,
"endTime": 463937.636059,
"url": "https://developer.mozilla.org/static/build/styles/subscriptions.3cebf84de805.css"
}
}
},
"request": {
"url": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs",
"transferSize": 61560,
"responseReceivedTime": 463937.594315,
"endTime": 463937.594317,
"startTime": 463937.53046
}
}
},
"longestChain": {
"transferSize": 1829,
"duration": 132.43300002068281,
"length": 2
}
}
},
"estimated-input-latency": {
"id": "estimated-input-latency",
"title": "Estimated Input Latency",
"description": "Estimated Input Latency is an estimate of how long your app takes to respond to user input, in milliseconds, during the busiest 5s window of page load. If your latency is higher than 50 ms, users may perceive your app as laggy. [Learn more](https://web.dev/estimated-input-latency/).",
"score": 1,
"scoreDisplayMode": "numeric",
"displayValue": "10 ms",
"numericValue": 12.8
},
"total-byte-weight": {
"id": "total-byte-weight",
"title": "Avoids enormous network payloads",
"description": "Large network payloads cost users real money and are highly correlated with long load times. [Learn more](https://web.dev/total-byte-weight/).",
"score": 1,
"scoreDisplayMode": "numeric",
"displayValue": "Total size was 330 KiB",
"details": {
"type": "table",
"headings": [
{
"itemType": "url",
"text": "URL",
"key": "url"
},
{
"text": "Transfer Size",
"itemType": "bytes",
"key": "totalBytes"
}
],
"items": [
{
"url": "https://developer.mozilla.org/static/build/js/react-main.739f5d7ca4fd.js",
"totalBytes": 93235
},
{
"totalBytes": 61560,
"url": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs"
},
{
"url": "https://developer.mozilla.org/static/build/styles/react-mdn.4e0ead71927e.css",
"totalBytes": 35533
},
{
"url": "https://developer.mozilla.org/static/fonts/locales/ZillaSlab-Bold.subset.e96c15f68c68.woff2",
"totalBytes": 34693
},
{
"url": "https://developer.mozilla.org/static/fonts/locales/ZillaSlab-Regular.subset.bbc33fb47cf6.woff2",
"totalBytes": 34437
},
{
"totalBytes": 19085,
"url": "https://www.google-analytics.com/analytics.js"
},
{
"url": "https://developer.mozilla.org/static/build/js/react-bcd-signal.cf0fc711cfa2.js",
"totalBytes": 8283
},
{
"url": "https://cdn.speedcurve.com/js/lux.js?id=108906238",
"totalBytes": 7537
},
{
"url": "https://developer.mozilla.org/static/img/web-docs-sprite.22a6a085cf14.svg",
"totalBytes": 4019
},
{
"url": "https://developer.mozilla.org/static/build/styles/react-header.78d662924939.css",
"totalBytes": 2284
}
]
},
"numericValue": 337833
},
"speed-index": {
"id": "speed-index",
"title": "Speed Index",
"description": "Speed Index shows how quickly the contents of a page are visibly populated. [Learn more](https://web.dev/speed-index/).",
"score": 0.99,
"scoreDisplayMode": "numeric",
"displayValue": "0.8 s",
"numericValue": 775.287095961904
},
"mainthread-work-breakdown": {
"id": "mainthread-work-breakdown",
"title": "Minimizes main-thread work",
"description": "Consider reducing the time spent parsing, compiling and executing JS. You may find delivering smaller JS payloads helps with this. [Learn more](https://web.dev/mainthread-work-breakdown/)",
"score": 1,
"scoreDisplayMode": "numeric",
"displayValue": "0.5 s",
"details": {
"type": "table",
"headings": [
{
"itemType": "text",
"text": "Category",
"key": "groupLabel"
},
{
"itemType": "ms",
"key": "duration",
"text": "Time Spent",
"granularity": 1
}
],
"items": [
{
"duration": 171.94199999999989,
"group": "scriptEvaluation",
"groupLabel": "Script Evaluation"
},
{
"group": "styleLayout",
"groupLabel": "Style & Layout",
"duration": 118.24500000000002
},
{
"group": "other",
"groupLabel": "Other",
"duration": 89.691999999999837
},
{
"groupLabel": "Rendering",
"duration": 32.649999999999984,
"group": "paintCompositeRender"
},
{
"groupLabel": "Parse HTML & CSS",
"duration": 28.025000000000002,
"group": "parseHTML"
},
{
"duration": 16.613,
"group": "scriptParseCompile",
"groupLabel": "Script Parsing & Compilation"
},
{
"group": "garbageCollection",
"groupLabel": "Garbage Collection",
"duration": 2.731
}
]
},
"numericValue": 459.89799999999968
},
"screenshot-thumbnails": {
"id": "screenshot-thumbnails",
"title": "Screenshot Thumbnails",
"description": "This is what the load of your site looked like.",
"score": null,
"scoreDisplayMode": "informative",
"details": {
"type": "filmstrip",
"items": [
{
"timing": 300,
"timestamp": 463937829358,
"data": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRQBAwQEBQQFCQUFCRQNCw0UFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFP/AABEIAFMAeAMBEQACEQEDEQH/xAGiAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgsQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+gEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoLEQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APrX4v2n7QV3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AqX13Itz5EMpilfG1ntZJIx65YEL06DI59c4qla2xnJ2e/wCBFpQv5ji4vLSdIyUkSKzeI9MgfNI2OCO3Ptmh2FFX6/ga9SajLiVYIJJGICopYkkAAAep6UAcsPFF5cJNcpGI7WCTaYj5DyTDYDtV1uNqtktywAwp46EgGWfGWrNaahOkluEiViJPLtisWLZ5ct/pvOf3bclflPOFbeoAyy8Z63JdRwL9nu2dodzQxW/y7o0ZuPtxPzbyygDhVP3+GYAty654gS0haOW2uJJVDuY7WIi3Hl7SrZvACVkwSVJGDtGfvAATUvGt1Za8mkxXNrPfyJO0emp9n+1sqoxik2tdKSpaOReF5IOfLCswAGN4q13yVlSBPneVZYnhtw1oCVEZkP23Hy87tuS29cbMEF2FdXsai6rrVzbbbYRTtOw8m+ht0aCJSCAzr9o3OM7WyvVWAwDkhBe50NhHcxWkSXk0dxcgYeWGIxqx9QpZiPzNAyxQAUAFAHEeO/EGoaRn7JcGH97bL91W4d2DdQeoAreEVLc451Jp2TKHw78UapresXMF7dGeKNHKqUUYxIQOQBngCipCMVoXSnKTsz0asDpCgBqxoo4UDtwKADYoz8o568daAEMSEg7FyDkHHegBwAHQYoAjuLWG7t5IJ4Y5oJFKvFIoZWB6gg8EHJoAkCgEnAyepxQKy3ECKpJAAJ9BQCSWw6gYUAFABQB//9k="
},
with the screenshot/data url being at the very bottom, it appears that the try catch may be hitting the catch but i cant tell why, does anyone have any ideas?

How to read Specific value from curl Response

this is my response
i need to read first line id value & url of sandbox
{
"id": "chg_g5Y25220190539Ob590811651",
"object": "charge",
"live_mode": false,
"api_version": "V2",
"method": "CREATE",
"status": "INITIATED",
"amount": 1.000,
"currency": "KWD",
"threeDSecure": false,
"card_threeDSecure": false,
"save_card": false,
"statement_descriptor": "Sample",
"description": "Test DESC",
"transaction":
{
"timezone": "UTC+03:00",
"created": "1573191592651",
"url": "https://sandbox.payments.tap.company/test_gosell/v2/payment/response.aspx?tap_chg=PsV8hZdr78kEIAOZl9XL1B5u3dXe%2bBQ%2b3Hrd%2fempxYs%3d&sess=noWi606EI%2bM%3d&token=PsV8hZdr78kEIAOZl9XL1B5u3dXe%2bBQ%2bTyYdQy9iGpS6aAXwKOqAdw%3d%3d",
"expiry": { "period": 30, "type": "MINUTE" },
"asynchronous": false
},
"reference": { "transaction": "txn_0001", "order": "ord_0001" },
"response": { "code": "100", "message": "Initiated" },
"receipt": { "email": true, "sms": true },
"customer": { "first_name": "yxy", "last_name": "ttt", "email": "xyx#xyz.com" },
"source": { "object": "source", "id": "src_card" },
"redirect": { "status": "PENDING", "url": "http://localhost:81/School/" },
"post": { "status": "PENDING", "url": "http://localhost:81/School/" } }
assuming you have your response from curl in a variable called $resp
$resp_decoded = json_decode($resp,TRUE);
print($resp_decoded['id']);
print($resp_decoded['transaction']['url']);

Facebook Access Token: MACHINE_ID

I did a little PHP script that uses this principle: https://developers.facebook.com/docs/facebook-login/access-tokens/expiration-and-extension#long-via-code
Unfortunately when I send the CODE to the user and try to HTTPrequest (javascript), the page that should give me the MACHINE_ID responds with a random, changing string.
I guess HTTPrequest is called basically from the server, not the client. When I use direct URL connection I get the same string every time, but I cannot use the data, because it is just a web page, not a response.
Shouldn't the MACHINE_ID always be the same (for a certain device/browser session)?
{
"session_key": "5.xLL8XelWvN17yQ.1530200602.46-100004938759387",
"uid": 100004938759387,
"secret": "62818f28dadf1e5fdea17c70cc42b4e5",
"access_token": "EAAAAUaZA8jlABAF8vs7Xp3bYhFrUjGZC7IJVIkBtsxGEbwjIhy7PtysyYCZB4ZBZAlXNvxSbsYZA9giZC8ZBhWZCpaTuYxGZBhGSo0sb1r5R8XPjmxbSHZCjuQgxjcgPlbVwsAVdboRHEyyc9cN6FfPFz3Jv9cB8xguVk4gyRCD6JQ5fhHBXxdykQwl",
"machine_id": "GgI1W1EjtchM9UoB1IiILZke",
"session_cookies": [{
"name": "c_user",
"value": "100004938759387",
"expires": "Fri, 28 Jun 2019 15:43:22 GMT",
"expires_timestamp": 1561736602,
"domain": ".facebook.com",
"path": "\/",
"secure": true
}, {
"name": "xs",
"value": "46:xLL8XelWvN17yQ:2:1530200602:15323:8134",
"expires": "Fri, 28 Jun 2019 15:43:22 GMT",
"expires_timestamp": 1561736602,
"domain": ".facebook.com",
"path": "\/",
"secure": true,
"httponly": true
}, {
"name": "fr",
"value": "0LpS1kk8BIpMZ6ZnX.AWUXzwpmVcljO_CD31ozKSBgHno.BYGKXA.3G.AAA.0.0.BbNQIa.AWUgcG86",
"expires": "Fri, 28 Jun 2019 15:43:22 GMT",
"expires_timestamp": 1561736602,
"domain": ".facebook.com",
"path": "\/",
"secure": true,
"httponly": true
}, {
"name": "datr",
"value": "GgI1W1EjtchM9UoB1IiILZke",
"expires": "Sat, 27 Jun 2020 15:43:22 GMT",
"expires_timestamp": 1593272602,
"domain": ".facebook.com",
"path": "\/",
"secure": true,
"httponly": true
}],
"confirmed": true,
"identifier": "Christian.palele",
"user_storage_key": "7086edcf13fb66e64be979ea719e8cd24d658ed3bce735e4f871dc69eda26409"
}

failed to open stream: Connection timed out error - Themoviedb

I need some help with the movie db api. I constantly get a connection timed out error. Below is my code, I'm trying to just output the raw json respone so I can work my way from there.
$header_opt = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept: application/json\r\n" .
"Content-Type: application/json\r\n"
)
);
$headers = stream_context_create($header_opt);
$rawjson = file_get_contents('http://api.themoviedb.org/3/movie/tt0076759?api_key=myapikey', false, $headers);
$cleansjon = json_decode($rawjson);
echo $cleansjon;
And this is the error I get.
Warning: filegetcontents(http://api.themoviedb.org/3/movie/tt0076759?api_key=myapikey) [function.file-get-contents]: failed to open stream: Connection timed out in /*///*/public_html/index.php on line 11
I hope that someone can help me with this.
Edit: Added HAR response
{
"log": {
"version": "1.2",
"creator": {
"name": "WebInspector",
"version": "537.20"
},
"pages": [
{
"startedDateTime": "2013-01-27T09:51:02.534Z",
"id": "page_1",
"title": "http://*MyWebsite*/tmdb.php",
"pageTimings": {
"onContentLoad": 60636,
"onLoad": 60635
}
}
],
"entries": [
{
"startedDateTime": "2013-01-27T09:51:02.534Z",
"time": 60197,
"request": {
"method": "GET",
"url": "http://*MyWebsite*/tmdb.php",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "DNT",
"value": "1"
},
{
"name": "Accept-Encoding",
"value": "gzip,deflate,sdch"
},
{
"name": "Host",
"value": "*MyHost*"
},
{
"name": "Accept-Language",
"value": "nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4"
},
{
"name": "User-Agent",
"value": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.20 (KHTML, like Gecko) Chrome/25.0.1328.0 Safari/537.20"
},
{
"name": "Accept",
"value": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
},
{
"name": "Cache-Control",
"value": "max-age=0"
},
{
"name": "Connection",
"value": "keep-alive"
},
{
"name": "Accept-Charset",
"value": "ISO-8859-1,utf-8;q=0.7,*;q=0.3"
}
],
"queryString": [],
"cookies": [],
"headersSize": 443,
"bodySize": 0
},
"response": {
"status": 200,
"statusText": "OK",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Date",
"value": "Sun, 27 Jan 2013 09:51:02 GMT"
},
{
"name": "Content-Encoding",
"value": "gzip"
},
{
"name": "Server",
"value": "Apache/2"
},
{
"name": "Vary",
"value": "Accept-Encoding,User-Agent"
},
{
"name": "Content-Type",
"value": "text/html"
},
{
"name": "Connection",
"value": "Keep-Alive"
},
{
"name": "Keep-Alive",
"value": "timeout=1, max=100"
},
{
"name": "Content-Length",
"value": "260"
}
],
"cookies": [],
"content": {
"size": 342,
"mimeType": "text/html",
"compression": 82
},
"redirectURL": "",
"headersSize": 234,
"bodySize": 260
},
"cache": {},
"timings": {
"blocked": 0,
"dns": 13,
"connect": 29,
"send": 0,
"wait": 60147,
"receive": 5,
"ssl": -1
},
"pageref": "page_1"
}
]
}
}
You can remove the Content-Type header, this would be required if you submit JSON using HTTP PUT or POST.
The error indicates, that file_get_contents does not get a response from the host api.themoviedb.org
I constantly get a connection timed out error.
Does constantly mean always or often?
If you see this frequently either your Internet uplink or the movie db server has a problem.
Maybe there is no problem at all. Your application is trying to connect to a server and gets a timeout error.

Categories