我正在尝试使用Ringcaptcha发送OTP并使用以下代码。
ALTER TABLE country DISABLE TRIGGER ALL;
INSERT INTO country .......
此代码不会每次都输出一个随机数。
$randnum = rand(100000,1000000);
$cmd = 'curl -k -X POST --data-urlencode "api_key=xxxxxxxxx" --data-urlencode "phone=+911234567890" --data-urlencode code=$randnum https://api.ringcaptcha.com/yyyyyyyyyyyy/code/sms';
exec($cmd,$result);
每次输出一个不同的数字,但curl不这样做。
我尝试了所有组合,例如','和“code =”。$ randnum等有人可以帮帮我吗?
答案 0 :(得分:0)
将Traceback (most recent call last):
File "/usr/src/app/backend/tests.py", line 779, in test_reactivate_contract
contract.activate_contract(paid=True, reactivate=True)
File "/usr/src/app/backend/models/contract.py", line 83, in activate_contract
revoke_task(self.celery_task)
File "/usr/src/app/backend/celery/tasks.py", line 128, in revoke_task
app.control.revoke(task_id)
File "/usr/local/lib/python3.6/site-packages/celery/app/control.py", line 210, in revoke
}, **kwargs)
File "/usr/local/lib/python3.6/site-packages/celery/app/control.py", line 436, in broadcast
limit, callback, channel=channel,
File "/usr/local/lib/python3.6/site-packages/kombu/pidbox.py", line 315, in _broadcast
serializer=serializer)
File "/usr/local/lib/python3.6/site-packages/kombu/pidbox.py", line 285, in _publish
with self.producer_or_acquire(producer, chan) as producer:
File "/usr/local/lib/python3.6/contextlib.py", line 81, in __enter__
return next(self.gen)
File "/usr/local/lib/python3.6/site-packages/kombu/pidbox.py", line 247, in producer_or_acquire
with self.producer_pool.acquire() as producer:
File "/usr/local/lib/python3.6/site-packages/kombu/resource.py", line 83, in acquire
R = self.prepare(R)
File "/usr/local/lib/python3.6/site-packages/kombu/pools.py", line 62, in prepare
p = p()
File "/usr/local/lib/python3.6/site-packages/kombu/utils/functional.py", line 203, in __call__
return self.evaluate()
File "/usr/local/lib/python3.6/site-packages/kombu/utils/functional.py", line 206, in evaluate
return self._fun(*self._args, **self._kwargs)
File "/usr/local/lib/python3.6/site-packages/kombu/pools.py", line 42, in create_producer
conn = self._acquire_connection()
File "/usr/local/lib/python3.6/site-packages/kombu/pools.py", line 39, in _acquire_connection
return self.connections.acquire(block=True)
File "/usr/local/lib/python3.6/site-packages/kombu/resource.py", line 78, in acquire
R = self._resource.get(block=block, timeout=timeout)
File "/usr/local/lib/python3.6/queue.py", line 164, in get
self.not_empty.wait()
File "/usr/local/lib/python3.6/threading.py", line 295, in wait
waiter.acquire()
File "/usr/local/lib/python3.6/site-packages/gevent/thread.py", line 84, in acquire
return BoundedSemaphore.acquire(self, blocking, timeout)
File "src/gevent/_semaphore.py", line 198, in gevent._semaphore.Semaphore.acquire (src/gevent/gevent._semaphore.c:4541)
File "src/gevent/_semaphore.py", line 226, in gevent._semaphore.Semaphore.acquire (src/gevent/gevent._semaphore.c:4367)
File "src/gevent/_semaphore.py", line 166, in gevent._semaphore.Semaphore._do_wait (src/gevent/gevent._semaphore.c:3562)
File "/usr/local/lib/python3.6/site-packages/gevent/hub.py", line 630, in switch
return RawGreenlet.switch(self)
gevent.hub.LoopExit: ('This operation would block forever', <Hub at 0x7fd1b0269210 epoll default pending=0 ref=0 fileno=4 resolver=<gevent.resolver_thread.Resolver at 0x7fd1a7843c50 pool=<ThreadPool at 0x7fd1a78432b0 0/1/10>> threadpool=<ThreadPool at 0x7fd1a78432b0 0/1/10>>)
替换为$echo randnum
。
答案 1 :(得分:0)
您可以将单引号更改为双引号,并将双引号更改为curl周围的单引号。如下所示。
$cmd = "curl -k -X POST --data-urlencode 'api_key=xxxxxxxx' --data-urlencode 'phone=+911234567890' --data-urlencode code=$randnum https://api.ringcaptcha.com/yyyyyyyyyyyy/code/sms";