Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libhuawei-hilink-perl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gerhard Gonter
libhuawei-hilink-perl
Commits
761b752e
Commit
761b752e
authored
Oct 4, 2020
by
Gerhard Gonter
Browse files
Options
Downloads
Patches
Plain Diff
some cleanup
parent
cfbca49f
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitignore
+4
-0
4 additions, 0 deletions
.gitignore
lib/Huawei/Hilink.pm
+13
-24
13 additions, 24 deletions
lib/Huawei/Hilink.pm
with
17 additions
and
24 deletions
.gitignore
0 → 100644
+
4
−
0
View file @
761b752e
.*.swp
misc/
list-sms
send-sms
This diff is collapsed.
Click to expand it.
lib/Huawei/Hilink.pm
+
13
−
24
View file @
761b752e
...
...
@@ -13,6 +13,7 @@ use XML::Simple;
my
$verbose
=
0
;
my
$debug
=
0
;
my
$standalone
=
0
;
my
%queries
=
(
...
...
@@ -95,19 +96,6 @@ sub send_sms
my
$url
=
'
http://
'
.
$self
->
{
gwip
}
.
'
/api/sms/send-sms
';
=begin comment
my @cmd= ('curl', $url,
'-H', 'Cookie: '. $session_id, '-H', '__RequestVerificationToken: ' . $token,
'--data', "<?xml version='1.0' encoding='UTF-8'?><request><Index>-1</Index><Phones><Phone>$phone</Phone></Phones><Sca></Sca><Content>$message</Content><Length>-1</Length><Reserved>1</Reserved><Date>-1</Date></request>");
push (@cmd, '-v') if ($debug);
print __LINE__, " cmd: ", join(' ', @cmd), "\n" if ($debug);
system(@cmd);
=end comment
=cut
my
$submit_data
=
"
<?xml version='1.0' encoding='UTF-8'?><request><Index>-1</Index><Phones><Phone>
$phone
</Phone></Phones><Sca></Sca><Content>
$message
</Content><Length>-1</Length><Reserved>1</Reserved><Date>-1</Date></request>
";
my
$ua
=
$self
->
{
_ua
}
||
(
$self
->
{
_ua
}
=
new
LWP::
UserAgent
());
...
...
@@ -121,10 +109,11 @@ sub send_sms
return
(
undef
,
undef
);
}
my
$result_data
=
$resp
->
decoded_content
;
print
__LINE__
,
"
result_data=[
$result_data
]
\n
";
my
$ref
=
XMLin
(
$result_data
);
print
__LINE__
,
"
ref:
",
Dumper
(
$ref
);
print
__LINE__
,
"
ref:
",
Dumper
(
$ref
)
if
(
$debug
||
$standalone
)
;
1
;
$ref
;
}
sub
list_sms
...
...
@@ -139,7 +128,7 @@ sub list_sms
my
(
$session_id
,
$token
)
=
$self
->
get_session
();
$ua
->
default_header
('
Cookie
',
$session_id
);
$ua
->
default_header
('
:__RequestVerificationToken
',
$token
);
$ua
->
default_header
('
X-Requested-With
',
'
XMLHttpRequest
');
#
#
$ua->default_header('X-Requested-With', 'XMLHttpRequest'); #
not needed
my
$submit_data
=
<<"EOX";
<request>
...
...
@@ -158,9 +147,11 @@ EOX
return
(
undef
,
undef
);
}
my
$result_data
=
$resp
->
decoded_content
;
print
__LINE__
,
"
result_data=[
$result_data
]
\n
";
my
$ref
=
XMLin
(
$result_data
);
print
__LINE__
,
"
ref:
",
Dumper
(
$ref
);
print
__LINE__
,
"
ref:
",
Dumper
(
$ref
)
if
(
$debug
||
$standalone
)
;
$ref
;
}
sub
query
...
...
@@ -189,13 +180,9 @@ sub query
$ua
->
default_header
('
Cookie
',
$session_id
);
$ua
->
default_header
('
:__RequestVerificationToken
',
$token
);
# $ua->default_header('X-Requested-With', 'XMLHttpRequest');
# $ua->default_header('X-Requested-With', 'XMLHttpRequest');
# not needed
}
# push (@cmd, '-v') if ($debug);
# print __LINE__, " cmd: ", join(' ', @cmd), "\n" if ($debug);
# system(@cmd);
my
$resp
=
$ua
->
get
(
$url
);
unless
(
$resp
->
is_success
)
{
...
...
@@ -204,14 +191,15 @@ sub query
}
my
$data
=
$resp
->
decoded_content
;
my
$ref
=
XMLin
(
$data
);
print
__LINE__
,
"
ref:
",
Dumper
(
$ref
);
print
__LINE__
,
"
ref:
",
Dumper
(
$ref
)
if
(
$debug
||
$standalone
)
;
1
;
$ref
;
}
sub
main
{
my
@PARS
;
push
(
@PARS
,
$
1
)
if
(
$
0
=~
m#(send-sms|list-sms)#
);
my
$gwip
=
'
192.168.8.1
';
while
(
my
$arg
=
shift
(
@ARGV
))
{
...
...
@@ -230,6 +218,7 @@ sub main
exit
(
1
);
}
$standalone
=
1
;
my
$obj
=
new
Huawei::
Hilink
(
gwip
=>
$gwip
);
my
$op_code
=
shift
(
@PARS
);
...
...
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