PHP examples
Categories
- 322 All Categories
- 3 Language datasets
- 9 News and updates
- 18 API endpoints
- 15 Review my code
- 6 Tutorials and presentations
- 92 Frequently asked questions
- 5 How to get useful technical help
- 2 Member guidelines
- 12 Suggest an improvement
- 58 Report a bug
- 9 Ask the Community: Other
- 54 Ask the Community: Technical and operational questions
- 61 General
PHP examples

Hi.
Can you include PHP examples as you do with Objective-C ?
Taking in count that PHP is the most used web language, it makes sence to have it.
Thanks
Comments
Hi @fkrum56,
We'll certainly pass your feedback on. Meanwhile, you can always find commercial and even open source software that generates snippets of code for specific tasks in all sorts of languages. For example, I have a tool called Postman which I use to make API calls so that I can reproduce issues people are asking about on this forum; that same tool can also produce snippets of example code for the call in question. Here is the example code for an entry call (ace) using the PHP HttpRequest option:
HI there, please provide an example in CURL, the follwin g is not workign
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'app_id: xxxx',
'app_key: xxxx'
));
Hi @xenium
Have you tried the tool my former colleague mentioned above, Postman?
I understand it is a free code-snippet generator, so you might be able to get the example you need.
hi Simone, thanks for your reply. I have briefly tried Postman but not had much luck yet, I was hoping to avoid having to learn how to use it just to get a few lines of code, but if I can find the time I will do a tutorial on it and then hopefully extract some working code.
Meanwhile if anyone has an example PHP script for a call to Oxford Dictionaries API that would be amazing!
Thanks again
Ok a bit of googling + Postman later here is some PHP, seems to work fine:
$app_key = 'yourappkey';
$app_id = 'yourappid';
$auth = array("app_key: $app_key", "app_id: $app_id");
$url = "https://od-api.oxforddictionaries.com:443/api/v2";
$endpoint = "entries";
$language_code = "en-us";
$lookup_word = "simple";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "$url/$endpoint/$language_code/$lookup_word",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => $auth,
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Hi @xenium
I'm glad it worked in the end - and many thanks for sharing the code!