我无法发布测试数据的问题是因为一旦有人试用了它就会被带走
它基本上是一个注册。它需要一个秘密ID和未使用的电子邮件。然后还有第二步,如果在步骤1中满足两个要求,则可以输入full_name和password。第二步是卷曲失败了,但使用邮差工作,我不知道为什么。这是邮递员出口:
https://gist.github.com/Jossnaz/31983240d57038ccb10afa88dd0765ae
这是我运行的天真代码,我使用这个卷曲包装器:
https://github.com/php-curl-class/php-curl-class
注意:我开始使用邮差中最小的东西,但是第二次调用不会起作用,所以我添加了更多我试过的东西并留下它们,这样你就可以看到我试过的东西没有期望它实际上会使它工作
试试这些:
$c->get("https://fond.co/public#/id_signup/themotcard.com");
设置饼干
设置用户代理,引用和原始标题
require(__DIR__ . '/vendor/autoload.php');
$c = new Curl();
$c->get("https://fond.co/public#/id_signup/themotcard.com");
$c->setHeader('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36');
$cookies = $c->getResponseCookies();
$c = new Curl();
$c->setCookies($cookies);
$c->setHeader('Content-Type', 'application/json');
$c->setHeader('Authorization', 'letmein');
$c->setHeader('X-Anyperk-Client-Id', 'AnyPerk-PublicApp/1/2');
$c->setHeader('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36');
$c->post('https://fond.co/api/public/company_staff_signup/signup',
[
"company_domain_name" => "themotcard.com",
"staff_identifier" => "35962466970",
"email" => "tesasdfaftasdxasdfaasdsasdfxabc22321@testabc.com",
]);
if ($c->error) {
echo 'Error: ' . $c->errorCode . ': ' . $c->errorMessage . "\n <br/>" . var_dump($c->response);
} else {
echo 'Response:' . "\n";
var_dump($c->response);
}
sleep(4)
echo "<br/>";
echo "<br/>";
echo "<br/>";
echo "<br/>";
$c = new Curl();
$c->setCookies($cookies);
$c->setHeader('Content-Type', 'application/json');
$c->setHeader('Authorization', 'letmein');
$c->setHeader('X-Anyperk-Client-Id', 'AnyPerk-PublicApp/1/2');
$c->setHeader('Host', 'fond.co');
$c->setHeader('Origin', 'https://fond.co');
$c->setHeader('Referer', 'https://fond.co/public');
$c->setHeader('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36');
$c->post('https://fond.co/api/public/company_staff_invitations/staff_details',
[
"full_name" => "lukas curl",
"password" => "test1x2x3x45"
]);
if ($c->error) {
echo 'Error: ' . $c->errorCode . ': ' . $c->errorMessage . "\n";
} else {
echo 'Response:' . "\n";
var_dump($c->response);
}
var_dump($c->response);
die('bb');
这是我得到的回应:
//step1, the logo indicates a successful submission and creation
Response: object(stdClass)#2592 (1) { ["logo_url"]=> string(104) "https://d17yvb56124x4l.cloudfront.net/company_informations/customized_logos/8709/original.png?1512057076" }
//step2
Error: 401: HTTP/1.1 401 Unauthorized object(stdClass)#2599 (1) { ["error"]=> string(12) "Unauthorized" } bb
答案 0 :(得分:0)
所以问题是饼干
此应用使用Cookie作为会话ID。 php curl还是guzzle或我试过的任何http客户端,存储了以下请求的cookie。因此导致401未经授权。
我最终使用guzzle btw,我只是尝试不同的http客户端,最后使用guzzle结束,这就是我想出了如何为第二次调用设置cookie的方法。
这是我的最终代码(睡眠设置为3秒,可能是一个人可以完全取消睡眠或将其设置为更少。我刚刚发现修复因此我将以3s睡眠发布)
require(__DIR__ . '/vendor/autoload.php');
$client = new GuzzleHttp\Client();
$res = $client->post('https://fond.co/api/public/company_staff_signup/signup', [
GuzzleHttp\RequestOptions::JSON =>
[
"company_domain_name" => "themotcard.com",
"staff_identifier" => "37952992345",
"email" => "tessyyyz3321@testabc.com",
]
,
GuzzleHttp\RequestOptions::HEADERS => [ 'x-anyperk-client-id' => 'AnyPerk-PublicApp/1/2',
'authorization' => 'letmein',
'content-type' => 'application/json']
]);
$cookieJar = new SessionCookieJar('motr_guzzle_sessioncookies', true);
sleep(3);
$request = new Request('POST', 'https://fond.co/api/public/company_staff_invitations/staff_details',
['x-anyperk-client-id' => 'AnyPerk-PublicApp/1/2',
'authorization' => 'letmein',
'content-type' => 'application/json'],
\GuzzleHttp\json_encode([
"full_name" => "lukas guzzle",
"password" => "test1x2x3x45"
])
);
$cookieJar->extractCookies($request, $res);
$request = $cookieJar->withCookieHeader($request);
$res = $client->send($request);
echo '<pre>';
var_dump($res);
echo '</pre>';