Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenApi-Papyros-PHP-Clients
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Σταύρος Παπαδάκης
OpenApi-Papyros-PHP-Clients
Commits
5c24912d
Commit
5c24912d
authored
Dec 23, 2016
by
Σταύρος Παπαδάκης
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get PDF function
parent
1c5ee0a3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
2 deletions
+41
-2
base-php-client/index.php
base-php-client/index.php
+13
-0
base-php-client/src/App.php
base-php-client/src/App.php
+17
-2
base-php-client/src/Client.php
base-php-client/src/Client.php
+11
-0
No files found.
base-php-client/index.php
View file @
5c24912d
...
...
@@ -130,5 +130,18 @@ if ($show) {
}
}
/**
* Λειτουργία λήψης αρχείου με δεδομένο hash id $options['save'] ή $options['get']
*/
if
(
$get
)
{
if
(
$save
)
{
$doc_details
=
$app
->
savePdf
(
$options
[
'save'
],
$apikey
);
echo
"Λεπτομέρειες αποθήκευσης εγγράφου: "
,
PHP_EOL
,
print_r
(
$doc_details
,
true
),
PHP_EOL
;
}
else
{
$doc_details
=
$app
->
getPdf
(
$options
[
'get'
],
$apikey
);
echo
"Λεπτομέρειες εγγράφου: "
,
PHP_EOL
,
print_r
(
$doc_details
,
true
),
PHP_EOL
;
}
}
echo
"Done."
,
PHP_EOL
;
exit
(
0
);
base-php-client/src/App.php
View file @
5c24912d
...
...
@@ -114,12 +114,27 @@ class App
public
function
getPdf
(
$hashid
,
$apikey
=
null
)
{
if
(
$this
->
_debug
)
{
echo
"getPdf:: hash id:
{
$hashid
}
"
,
PHP_EOL
;
}
$response
=
json_decode
(
$this
->
client
->
getPdf
(
$hashid
,
$apikey
===
null
?
$this
->
getApiKey
()
:
$apikey
),
true
);
return
$response
;
}
public
function
savePdf
(
$hashid
,
$apikey
=
null
)
{
if
(
$this
->
_debug
)
{
echo
"savePdf:: hash id:
{
$hashid
}
"
,
PHP_EOL
;
}
$result
=
$this
->
getPdf
(
$hashid
,
$apikey
=
null
);
$save
=
file_put_contents
(
$result
[
"fileName"
],
base64_decode
(
$result
[
"document"
][
"base64"
]));
return
[
'file_name'
=>
$result
[
"fileName"
],
'description'
=>
$result
[
"description"
],
'save'
=>
(
$save
?
'Αποθηκεύτηκε'
:
'ΔΕΝ αποθηκεύθηκε'
)
];
}
/**
...
...
base-php-client/src/Client.php
View file @
5c24912d
...
...
@@ -56,6 +56,17 @@ class Client
return
$result
;
}
public
function
getPdf
(
$hashid
,
$apikey
)
{
$result
=
$this
->
get
(
"
{
$this
->
_settings
[
'base_uri'
]
}
/document/pdf/
{
$hashid
}
"
,
[],
[
"api_key:
{
$apikey
}
"
,
"Content-Type: text/plain"
,
"Accept: application/json"
,
]
);
return
$result
;
}
protected
function
setCommonCurlOptions
(
$ch
,
$uri
,
$headers
)
{
curl_setopt
(
$ch
,
CURLOPT_URL
,
$uri
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment