- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试从华为 E8372 发送短信,与该产品的旧版本不同,它现在需要登录(用户名/密码)才能进行 API 调用。来自 https://github.com/arska/e3372/issues/1我已经能够更新 arasaahov 编写的代码,如下所示,这让我通过了登录步骤(我可以获得 SESSION_ID cookie 和 token )
#!/bin/sh
# Script updated from example here: https://github.com/arska/e3372/issues/1
MODEM_IP="192.168.8.1"
message="Hello world"
phone="PHONE NUMBER HERE"
echo "Get the Session token information from http://$MODEM_IP/api/webserver/SesTokInfo"
curl -s -X GET "http://$MODEM_IP/api/webserver/SesTokInfo" > ses_tok.xml
# Echo the ses_tok.xml file
#cat ses_tok.xml
# Now pull out the important stuff
echo ""
echo ""
echo "Now pull the important stuff out"
COOKIE=`grep "SessionID=" ses_tok.xml | cut -b 10-147`
TOKEN=`grep "TokInfo" ses_tok.xml | cut -b 10-41`
LOGIN_REQ="<request><Username>admin</Username><Password>YWRtaW4=</Password><password_type>3</password_type></request>"
echo "COOKIE: $COOKIE"
echo "TOKEN: $TOKEN"
echo "LOGIN REQ: $LOGIN_REQ"
echo "\n"
# Now lets actually login
curl -v -X POST -d $LOGIN_REQ "http://$MODEM_IP/api/user/login" \
-H "Cookie: $COOKIE" -H "__RequestVerificationToken: $TOKEN" -H "Content-Type: text/xml" -H 'Connection: keep-alive' \
--dump-header login_resp_hdr.txt # > /dev/null
# Pull the important parts out
SESSION_ID=$(grep "SessionID=" login_resp_hdr.txt | cut -d ':' -f2 | cut -d ';' -f1)
ADM_TOKEN=$(grep "__RequestVerificationTokenone" login_resp_hdr.txt | cut -d ':' -f2)
echo "\n"
echo "admin SESSION_ID is: $SESSION_ID"
echo "admin TOKEN is: $ADM_TOKEN"
message_data="<request><Index>-1</Index><Phones><Phone>$phone</Phone></Phones><Sca></Sca><Content>hello</Content><Length>5</Length><Reserved>1</Reserved><Date>1</Date></request>"
# Send an SMS
#curl -X POST -d $message_data "http://$MODEM_IP/api/sms/send-sms" -H "Cookie: $SESSION_ID" -H "__RequestVerificationToken: $ADM_TOKEN" -H "Content-Type: text/xml" #--dump-header send_result.txt
curl -v http://192.168.8.1/api/sms/send-sms \
-H "Cookie: $SESSION_ID" \
-H "__RequestVerificationToken: $ADM_TOKEN" \
-H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" \
-H "Accept: */*" \
-H "Referer: http://192.168.8.1/html/smsinbox.html" \
-H "Content-Type: text/xml" \
-H "Connection: keep-alive" \
-H "Origin: http://192.168.8.1" \
--data $message_data \
--dump-header send_result.txt
但是,我收到错误返回“100005”,我认为这意味着我的 send-sms 命令不正确。脚本的完整输出如下:
Get the Session token information from http://192.168.8.1/api/webserver/SesTokInfo
Now pull the important stuff out
COOKIE: SessionID=bqveiiBGuCLn8kzilf/7JGUbly53F9EaGFpcJL5gNkg+HvkhC5NpE51pyC7wrTaZQGOJKfdYqnhGWEGU06BPyyknGvsPZvD2QbPzKPh7GvXIiBBL6N9BW7SnrFYh/X0J
TOKEN: pFAF3FZcWziTDWlthllgIDRGbPSFERuH
LOGIN REQ: <request><Username>admin</Username><Password>YWRtaW4=</Password><password_type>3</password_type></request>
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 192.168.8.1...
* TCP_NODELAY set
* Connected to 192.168.8.1 (192.168.8.1) port 80 (#0)
> POST /api/user/login HTTP/1.1
> Host: 192.168.8.1
> User-Agent: curl/7.52.1
> Accept: */*
> Cookie: SessionID=bqveiiBGuCLn8kzilf/7JGUbly53F9EaGFpcJL5gNkg+HvkhC5NpE51pyC7wrTaZQGOJKfdYqnhGWEGU06BPyyknGvsPZvD2QbPzKPh7GvXIiBBL6N9BW7SnrFYh/X0J
> __RequestVerificationToken: pFAF3FZcWziTDWlthllgIDRGbPSFERuH
> Content-Type: text/xml
> Connection: keep-alive
> Content-Length: 106
>
* upload completely sent off: 106 out of 106 bytes
< HTTP/1.1 200 OK
< Date: Thu, 01 Jan 1970 00:00:00 GMT
< Server: WebServer
< Connection: close
< X-Download-Options: noopen
< X-Frame-Options: deny
< X-XSS-Protection: 1; mode=block
< Strict-Transport-Security: max-age=31536000; includeSubdomains
< Cache-Control: no-cache
< Content-Type: text/html
< Content-Length: 61
< __RequestVerificationTokenone:xDaZ9B6udQl7GRMyrfaI7WDKF6hM3Icr
< __RequestVerificationTokentwo:oTKseE/iBAYbF1FUJ8XJ9+/X0ulxh+jt
< __RequestVerificationToken:xDaZ9B6udQl7GRMyrfaI7WDKF6hM3Icr#oTKseE/iBAYbF1FUJ8XJ9+/X0ulxh+jt#4M8V6iAWXbfDDlKW0WSForGtB2ZhuUyC#0FWYnCHKcKRX36MD1tgOkiStsT6OF5+O#iLyskoatpK+Ch6pH4PpgZ8Pr8zErrg9P#0yBQ0bbowQL2iZ3QW3FN4q0Adls16LTR#5P6wjHVOMNgGQYkdvBqohZGyQRTr0968#xEdi5v1dsQerDVYXz1fH4HCHMYnEiwy2#BAMuBOJoiJOY33vUENbN+cnSc3yueLQ6#Or4N+mktvSse35qIh6YqLB3lbf2LccFf#il1DNPB/0iEjUMPBgN9icxp58dkHYdNB#ZkltJCROvVHhKf676y+bhBy1Sv27M2Np#tdZgoksZu2o1q3dvS/oYNRYoH+7kTcuv#oqML4IGNmrS06DR5n6jWjzTA4yYakO0S#5di87l60XdJF0xPs3QSKMt2LELP+pEJA#fhRNe9lpisoy+3hhJyM/FWhKVQ13Lu+k#AagfENLE7/Hqm/RReQi7fKhASsaX6qm8#BL3sFmPVQl4RUYwROo3pY31I1ee0sgCM#u+VyGVo2GBe1tX81gJK+hXoYi2jOo+iE#Y//frYpRi+BaeZ7ziflACD1KNgI7SsNI#KAyJoAu0c9reXYf3oBDyl11rU8pkj16h#Ohc04aUEkes0qw/UaGFwK3l5brC9kfEb#GJS9B0d9cFbi2ChCxD16KxpiCx2H3UZT#ECxR86GG9rxnYkVpENGR8Km0srn/Nc6W#cvBDKis3DNqw7a1mtJkvei/NhyPfg3vw#YBQeG0Btnf03ejEhMp/ciQ2T5Lj93bnL#uJ3K1UMLwjSQw+kq6L7slBZcwHFRDcBf#edK//KWWp6BmUsufzVeIG2TmgBqvZ6gL#12TMh7qa/AuBO+EkgXlvzSax/p4wRAAm#CiZltXfOF4jrSoiUm5MKffam0hBU55+s#FNoUhUP7xQtnyNO3tjX01pTjQbzqwkz9#HgPuo6xLxkBcQ3z7LwReWEohfnrlJNZI#
< Set-Cookie:SessionID=vfyx1z/vIhtiTPJxA3gnptVVeCVwYo18IIuolHeAIbHbsn8xphH++92zOgu4selkbQ+1CyuuC4nvzyrRj/DV/12Jma+nVsewcQyinv9eXGzsxtQcihQeqCp2RMEmm0xy;path=/;HttpOnly;
<
* Curl_http_done: called premature == 0
* Closing connection 0
<?xml version="1.0" encoding="UTF-8"?><response>OK</response>
admin SESSION_ID is: SessionID=vfyx1z/vIhtiTPJxA3gnptVVeCVwYo18IIuolHeAIbHbsn8xphH++92zOgu4selkbQ+1CyuuC4nvzyrRj/DV/12Jma+nVsewcQyinv9eXGzsxtQcihQeqCp2RMEmm0xy
admin TOKEN is: xDaZ9B6udQl7GRMyrfaI7WDKF6hM3Icr
* Trying 192.168.8.1...
* TCP_NODELAY set
* Connected to 192.168.8.1 (192.168.8.1) port 80 (#0)
> POST /api/sms/send-sms HTTP/1.1
> Host: 192.168.8.1
> User-Agent: curl/7.52.1
> Cookie: SessionID=vfyx1z/vIhtiTPJxA3gnptVVeCVwYo18IIuolHeAIbHbsn8xphH++92zOgu4selkbQ+1CyuuC4nvzyrRj/DV/12Jma+nVsewcQyinv9eXGzsxtQcihQeqCp2RMEmm0xy
> __RequestVerificationToken: xDaZ9B6udQl7GRMyrfaI7WDKF6hM3Icr
> Content-Type: application/x-www-form-urlencoded; charset=UTF-8
> Accept: */*
> Referer: http://192.168.8.1/html/smsinbox.html
> Content-Type: text/xml
> Connection: keep-alive
> Origin: http://192.168.8.1
> Content-Length: 167
>
* upload completely sent off: 167 out of 167 bytes
< HTTP/1.1 200 OK
< Date: Thu, 01 Jan 1970 00:00:00 GMT
< Server: WebServer
< Connection: close
< X-Download-Options: noopen
< X-Frame-Options: deny
< X-XSS-Protection: 1; mode=block
< Strict-Transport-Security: max-age=31536000; includeSubdomains
< Cache-Control: no-cache
< Content-Type: text/html
< Content-Length: 101
< __RequestVerificationToken:QKB4o80G00DALXLfhiwqjhJBhaSuE0mM
<
<?xml version="1.0" encoding="UTF-8"?>
<error>
<code>100005</code>
<message></message>
</error>
* Curl_http_done: called premature == 0
* Closing connection 0
HTTP/1.1 200 OK
Date: Thu, 01 Jan 1970 00:00:00 GMT
Server: WebServer
Connection: close
X-Download-Options: noopen
X-Frame-Options: deny
X-XSS-Protection: 1; mode=block
Strict-Transport-Security: max-age=31536000; includeSubdomains
Cache-Control: no-cache
Content-Type: text/html
Content-Length: 101
__RequestVerificationToken:QKB4o80G00DALXLfhiwqjhJBhaSuE0mM
任何人都可以帮助解决我做错的事情吗?多谢!
最佳答案
明白了!您必须将 SESSION_ID cookie 传递给/api/webserver/sesTokInfo 以获取新的 token (TokInfo) - 这会替换以前版本固件的/api/webserver/token 调用。所以一旦登录,
下面获取一个新 token ,存储为 ADM_TOKEN
curl -s -X GET "http://$MODEM_IP/api/webserver/SesTokInfo" \
-H "Cookie: $SESSION_ID" > ses_tok2.xml
ADM_TOKEN=`grep "TokInfo" ses_tok2.xml | cut -b 10-41`
然后您可以使用该 ADM_TOKEN 运行下一个命令
curl -v http://192.168.8.1/api/sms/send-sms \
-H "Cookie: $SESSION_ID" \
-H "__RequestVerificationToken: $ADM_TOKEN" \
-H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" \
-H "Accept: */*" \
-H "Referer: http://192.168.8.1/html/smsinbox.html" \
-H 'X-Requested-With: XMLHttpRequest' \
-H "Connection: keep-alive" \
-H "Origin: http://192.168.8.1" \
--data $message_data \
--dump-header send_result.txt
看起来你想要运行的每个命令都必须先获得一个新 token
关于bash - 使用华为 E8372 hilink 通过 bash 脚本发送短信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48728233/
您好,我在最后一步使用了 add 和 offer 来添加我的元素。两者都返回 boolean 值,并且除了 NPE 之外都不会抛出任何异常。 public class ArrayDequeDemo
我正在做一个功能,用户的电子邮件客户端只打开一个预填充的内容 (javascript)。 问题是我在转换特殊字符时遇到问题,因此它们无法正确显示到电子邮件客户端(内容由 url 传递)。 我写了一个函
问题一: 在阅读 JDK 源代码时,我发现该方法 boolean add(E e);在接口(interface)中定义 Collection & Queue & BlockingQueue . 我无法
我想比较 SQL 中的两个 varchar,一个类似于 Cafe ,另一个 Café SQL 中是否有一种方法可以允许这两个值进行比较。例如: SELECT * FROM Venue WHERE Na
我正在研究一种方法来搜索文本中的特定单词并突出显示它们。该代码工作完美,除了我希望它也匹配相似的字母。我的意思是,搜索 fête 应该匹配 fêté、fete、... 有没有一种简单而优雅的方法来做到
所以我有一个非常简单的组件,它加载了一个简单的路由器。我正在使用所有基本的东西,比如 ngFor、ngSwitch、ngIf,我通过 COMMON_DIRECTIVES 注入(inject)它们 我收
我有一个类似 Brazil: Série A 的字符串,我的目标是转换为 Brazil: Serie A。 此外,方法应该转换和其他类似的情况:é -> e, š -> s, ė -> e , ą -
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
在我的 app.module.ts @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule
Sample查询: SELECT e FROM Employee e WHERE SUBSTRING(e.name, 3) = 'Mac' 在这种语法中,说 SELECT e 似乎很直观,即 e 现在
objective-c 中是否有一种简单的方法可以将所有特殊字符(如 ë、à、é、ä)转换为普通字符(如 e en a)? 最佳答案 是的,而且非常简单: NSString *src = @"Conv
我想将 ë 之类的字符转换为普通的 e。我正在寻找关于语言和人们如何输入城市的转换。例如,大多数人在搜索时实际上输入的是 Brasilia,而不是 Brasília。当 Rueters 等新闻机构报道
当我写作时 $("#new_lang").click(function(e) { alert("something"); e.stopPropagation(); }); 这里的 e 是什么,
> 的键是 E 的某些属性,值是具有该属性的 E
我想知道如何将 Java List 转换为 Map。映射中的键是列表元素的某些属性(不同的元素可能具有相同的属性),值是这些列表项的列表(具有相同的属性)。例如。 List --> Map> 。我找到
我试图理解,为什么我们需要 Deque 中的 Offer 和 OfferLast 方法,因为这两种方法都在Deque 的结尾/尾部。它有什么意义? 最佳答案 Queue 接口(interface)是在
这个问题是这个问题的延续 here .如果有人想知道为什么我需要做这样的事情,你可以在那个问题中找到理由。这并不重要,真的。 我需要这样的方法: public virtual Expression>
注意:这个问题与 Enum 无关,所以它不是重复的。Enum 被迫只与自身比较,因为编译器生成类型参数,而不是因为 java 递归类型参数。 我试图找到将类声明为的优势: public class S
注意:这个问题与 Enum 无关,所以它不是重复的。Enum 被迫只与自身比较,因为编译器生成类型参数,而不是因为 java 递归类型参数。 我试图找到将类声明为的优势: public class S
如果我有一个struct example *e,function(&e) 和function(e) 之间有什么区别? 一个例子。 这是第一个代码: #include struct example {
这个问题在这里已经有了答案: C# 7.0 ValueTuples vs Anonymous Types (2 个答案) 关闭去年。 这两个查询有什么区别? var query = from e i
我是一名优秀的程序员,十分优秀!