Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OpenApi-Papyros-PHP-Clients
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Σταύρος Παπαδάκης
OpenApi-Papyros-PHP-Clients
Commits
bbfa3270
Commit
bbfa3270
authored
8 years ago
by
Σταύρος Παπαδάκης
Browse files
Options
Downloads
Patches
Plain Diff
Post protocol function
parent
5c24912d
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
base-php-client/index.php
+44
-0
44 additions, 0 deletions
base-php-client/index.php
base-php-client/src/App.php
+13
-2
13 additions, 2 deletions
base-php-client/src/App.php
base-php-client/src/Client.php
+11
-0
11 additions, 0 deletions
base-php-client/src/Client.php
with
68 additions
and
2 deletions
base-php-client/index.php
+
44
−
0
View file @
bbfa3270
...
...
@@ -82,6 +82,50 @@ try {
exit
(
-
1
);
}
/**
* Αποστολή αρχείου για πρωτοκόλληση
*/
if
(
$send
)
{
echo
"Αποστολή εγγράφου..."
,
PHP_EOL
;
echo
"Έλεγχος για το αρχείο
{
$options
[
'send'
]
}
... "
;
if
(
is_readable
(
$options
[
'send'
]))
{
$file
=
base64_encode
(
file_get_contents
(
$options
[
'send'
]));
if
(
$file
===
false
)
{
echo
PHP_EOL
,
"ΛΑΘΟΣ: Αδυναμία κωδικοποίησης του αρχείου."
,
PHP_EOL
;
}
echo
"OK"
,
PHP_EOL
;
}
else
{
echo
PHP_EOL
,
"ΛΑΘΟΣ: Το αρχείο δεν είναι αναγνώσιμο."
,
PHP_EOL
;
exit
(
-
1
);
}
try
{
// καθορισμός παραμέτρων σε πίνακα για απλοποίηση
$submission_data
=
[
'theme'
=>
'ΔΟΚΙΜΗ: Αυτοματοποιημένο κείμενο της '
.
date
(
'c'
),
'description'
=>
'ΔΟΚΙΜΗ: Αυτοματοποιημένο κείμενο περιγραφής '
.
date
(
'Ymdhmi'
),
'docCategory'
=>
20
,
'mainDoc'
=>
[
'document'
=>
[
"base64"
=>
$file
],
'fileName'
=>
$options
[
'send'
],
'description'
=>
"ΔΟΚΙΜΗ: Αποστολή δοκιμαστικού αρχείου
{
$options
[
'send'
]
}
"
]
// το παράδειγμα δεν περιλαμβάνει συνημμένα αρχεία
// και ορισμένες επιπλέον παραμέτρους
// senderId, senderProtocol, senderProtocolDate, ada, attachedDoc[]
];
$doc_info
=
$app
->
postProtocol
(
$submission_data
,
$apikey
);
echo
"Η αποστολή ολοκληρώθηκε με ΑΡ.Π.: "
,
$doc_info
[
"protocolNumber"
],
PHP_EOL
;
echo
"Αναλυτικά: "
,
print_r
(
$doc_info
,
true
),
PHP_EOL
;
}
catch
(
\Exception
$e
)
{
echo
'ΛΑΘΟΣ: Αδυναμία αποστολής εγγράφου. '
,
PHP_EOL
,
$e
->
getMessage
(),
PHP_EOL
;
exit
(
1
);
}
}
/**
* Λειτουργία λήψης λίστας των καταχωρημένων πρωτοκόλλων.
* Εάν έχει ζητηθεί επιστρέφονται και οι αναλυτικές πληροφορίες των εγγράφων.
...
...
This diff is collapsed.
Click to expand it.
base-php-client/src/App.php
+
13
−
2
View file @
bbfa3270
...
...
@@ -107,9 +107,20 @@ class App
return
$response
;
}
public
function
submit
(
$submission_data
,
$apikey
=
null
)
public
function
postProtocol
(
$submission_data
,
$apikey
=
null
)
{
$payload
=
json_encode
(
array_merge
([
'senderId'
=>
$this
->
setting
(
'sender_id'
),
],
$submission_data
)
);
if
(
$this
->
_debug
)
{
echo
"postProtocol :: payload:
{
$payload
}
"
,
PHP_EOL
;
}
$response
=
json_decode
(
$this
->
client
->
postProtocol
(
$payload
,
$apikey
===
null
?
$this
->
getApiKey
()
:
$apikey
),
true
);
return
$response
;
}
public
function
getPdf
(
$hashid
,
$apikey
=
null
)
...
...
This diff is collapsed.
Click to expand it.
base-php-client/src/Client.php
+
11
−
0
View file @
bbfa3270
...
...
@@ -67,6 +67,17 @@ class Client
return
$result
;
}
public
function
postProtocol
(
$payload
,
$apikey
)
{
$result
=
$this
->
post
(
"
{
$this
->
_settings
[
'base_uri'
]
}
/protocol/submit"
,
$payload
,
[
"api_key:
{
$apikey
}
"
,
"Content-Type: application/json"
,
"Accept: application/json"
,
]
);
return
$result
;
}
protected
function
setCommonCurlOptions
(
$ch
,
$uri
,
$headers
)
{
curl_setopt
(
$ch
,
CURLOPT_URL
,
$uri
);
...
...
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