-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrainly.php
57 lines (54 loc) · 1.28 KB
/
brainly.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* @author Rachma Azis <[email protected]>
* @version 1.0
* Fb : https://www.facebook.com/azis.riaz
* IG : @azisek_
*/
function Brainly($q){
$headers = array();
$headers[] = 'Content-Type: application/json; charset=utf-8';
$headers[] = 'user-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:65.0) Gecko/20100101 Firefox/65.0';
$formatGraphQl = 'query SearchQuery($query: String!, $first: Int!, $after: ID) {
questionSearch(query: $query, first: $first, after: $after) {
edges {
node {
content
attachments{
url
}
answers {
nodes {
content
attachments{
url
}
}
}
}
}
}
}
';
$count = 2;
$query = array('operationName' => 'SearchQuery',
'variables' => [
'query' => $q,
'after' => null,
'first' => 100
],
'query' => $formatGraphQl);
$data = json_encode($query);
$curl = curl_init();
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:65.0) Gecko/20100101 Firefox/65.0");
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'https://brainly.co.id/graphql/id',
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $data
]);
$response = curl_exec($curl);
return $response;
}
?>