@@ -41,13 +41,11 @@ function get_bearer_token(){
41
41
curl_setopt ($ ch , CURLOPT_URL ,$ url ); // set url to send to
42
42
curl_setopt ($ ch , CURLOPT_HTTPHEADER , $ headers ); // set custom headers
43
43
curl_setopt ($ ch , CURLOPT_POST , 1 ); // send as post
44
+ curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true ); // return output
44
45
curl_setopt ($ ch , CURLOPT_POSTFIELDS , "grant_type=client_credentials " ); // post body/fields to be sent
45
46
$ header = curl_setopt ($ ch , CURLOPT_HEADER , 1 ); // send custom headers
46
47
$ httpcode = curl_getinfo ($ ch , CURLINFO_HTTP_CODE );
47
- ob_start (); // start ouput buffering
48
- curl_exec ($ ch ); // execute the curl
49
- $ retrievedhtml = ob_get_contents (); // grab the retreived html
50
- ob_end_clean (); //End buffering and clean output
48
+ $ retrievedhtml = curl_exec ($ ch ); // execute the curl
51
49
curl_close ($ ch ); // close the curl
52
50
$ output = explode ("\n" , $ retrievedhtml );
53
51
$ bearer_token = '' ;
@@ -90,13 +88,11 @@ function invalidate_bearer_token($bearer_token){
90
88
curl_setopt ($ ch , CURLOPT_URL ,$ url ); // set url to send to
91
89
curl_setopt ($ ch , CURLOPT_HTTPHEADER , $ headers ); // set custom headers
92
90
curl_setopt ($ ch , CURLOPT_POST , 1 ); // send as post
91
+ curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true ); // return output
93
92
curl_setopt ($ ch , CURLOPT_POSTFIELDS , "access_token= " .$ bearer_token ."" ); // post body/fields to be sent
94
93
$ header = curl_setopt ($ ch , CURLOPT_HEADER , 1 ); // send custom headers
95
94
$ httpcode = curl_getinfo ($ ch , CURLINFO_HTTP_CODE );
96
- ob_start (); // start ouput buffering
97
- curl_exec ($ ch ); // execute the curl
98
- $ retrievedhtml = ob_get_contents (); // grab the retreived html
99
- ob_end_clean (); //End buffering and clean output
95
+ $ retrievedhtml = curl_exec ($ ch ); // execute the curl
100
96
curl_close ($ ch ); // close the curl
101
97
return $ retrievedhtml ;
102
98
}
@@ -123,10 +119,8 @@ function search_for_a_term($bearer_token, $query, $result_type='mixed', $rpp='15
123
119
$ ch = curl_init (); // setup a curl
124
120
curl_setopt ($ ch , CURLOPT_URL ,$ url .$ formed_url ); // set url to send to
125
121
curl_setopt ($ ch , CURLOPT_HTTPHEADER , $ headers ); // set custom headers
126
- ob_start (); // start ouput buffering
127
- $ output = curl_exec ($ ch ); // execute the curl
128
- $ retrievedhtml = ob_get_contents (); // grab the retreived html
129
- ob_end_clean (); //End buffering and clean output
122
+ curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true ); // return output
123
+ $ retrievedhtml = curl_exec ($ ch ); // execute the curl
130
124
curl_close ($ ch ); // close the curl
131
125
return $ retrievedhtml ;
132
126
}
@@ -135,4 +129,4 @@ function search_for_a_term($bearer_token, $query, $result_type='mixed', $rpp='15
135
129
$ bearer_token = get_bearer_token (); // get the bearer token
136
130
print search_for_a_term ($ bearer_token , "test " ); // search for the work 'test'
137
131
invalidate_bearer_token ($ bearer_token ); // invalidate the token
138
- ?>
132
+ ?>
0 commit comments