Last active
July 10, 2019 12:40
-
-
Save nobodyplace/5d6b04b9c186a07dace7a71034d7c3df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $client = new \GuzzleHttp\Client([ | |
| 'base_uri' => 'https://example.com/wp-json/wp/v2/' | |
| ]); | |
| $response = $client->get('media',[ | |
| 'query' => ['search' => 'sample'] | |
| ]); | |
| $result = json_decode($response->getBody()->getContents()); | |
| return (count($result)) ? $result[0]->id : null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $client = new \GuzzleHttp\Client([ | |
| 'base_uri' => 'https://example.com/wp-json/wp/v2/' | |
| ]); | |
| $response = $client->get('media',[ | |
| 'query' => ['title' => 'sample'] | |
| ]); | |
| $result = json_decode($response->getBody()->getContents()); | |
| return (count($result)) ? $result[0]->id : null; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment