Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
TypoScript-Forger
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TYPO3
TypoScript-Forger
Commits
cf456f36
Commit
cf456f36
authored
9 years ago
by
damjan
Browse files
Options
Downloads
Patches
Plain Diff
[FEATURE] Using curl in controller to get attributes from REST API
parent
e3c5bd89
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Classes/SGalinski/TypoScriptReferenceFrontend/Controller/TsrefController.php
+48
-4
48 additions, 4 deletions
...ypoScriptReferenceFrontend/Controller/TsrefController.php
with
48 additions
and
4 deletions
Classes/SGalinski/TypoScriptReferenceFrontend/Controller/TsrefController.php
+
48
−
4
View file @
cf456f36
...
...
@@ -10,14 +10,58 @@ namespace SGalinski\TypoScriptReferenceFrontend\Controller;
use
TYPO3\Flow\Annotations
as
Flow
;
class
TsrefController
extends
\TYPO3\Flow\Mvc\Controller\ActionController
{
/**
* @return void
*/
public
function
indexAction
()
{
$this
->
view
->
assign
(
'foos'
,
array
(
'bar'
,
'baz'
));
$jsonAttributes
=
$this
->
curl_download
(
'http://127.0.0.1:8000/api/attributes'
);
$this
->
view
->
assign
(
'foos'
,
[
'bar'
,
$jsonAttributes
]
);
}
function
curl_download
(
$Url
)
{
// is cURL installed yet?
if
(
!
function_exists
(
'curl_init'
))
{
die
(
'Sorry cURL is not installed!'
);
}
// OK cool - then let's create a new cURL resource handle
$ch
=
curl_init
();
// Now set some options (most are optional)
// Set URL to download
curl_setopt
(
$ch
,
CURLOPT_URL
,
$Url
);
// Set a referer
// curl_setopt($ch, CURLOPT_REFERER, "http://www.example.org/yay.htm");
// // User agent
// curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
// Include header in result? (0 = yes, 1 = no)
// curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt
(
$ch
,
CURLOPT_HTTPHEADER
,
array
(
'istype: 1'
));
// Should cURL return or print out the data? (true = return, false = print)
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
TRUE
);
// Timeout in seconds
curl_setopt
(
$ch
,
CURLOPT_TIMEOUT
,
10
);
// Download the given URL, and return output
$output
=
curl_exec
(
$ch
);
// Close the cURL resource, and free system resources
curl_close
(
$ch
);
return
$output
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment