 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
XPertDeveloper.com: Get Facebook Page Detail Using Graph API and PHP
by Chris Cornutt January 03, 2012 @ 11:06:04
New from the XPertDeveloper.com blog there's a tutorial showing how to use the Facebook graph API to get page details via a simple cURL request (cURL PHP support required for the example).
Here is the technique to get the detail of the Facebook page with Graph API and PHP. This is the very easy method to get the Facebook page detail. So Let's see how to get this done. With this method you can get details of any Facebook page [inluding] name, picture, link, website, products, description and if the user can post to it.
The sample code is only a few lines - it uses the Facebook page ID (easy to grab from the URL) and fetches a URL with it as a parameter. The output is returned as a standard PHP object with all of the properties attached (decoded from JSON). This is just one of many methods the Facebook graph API has, so check out their documentation for more methods and details on returned values.
voice your opinion now!
facebook graph api curl request tutorial
Lorna Mitchell's Blog: POSTing JSON Data With PHP cURL
by Chris Cornutt November 22, 2011 @ 18:06:48
On her blog today Lorna Mitchell has a quick tip for anyone having an issue sending POSTed JSON data with the curl functionality that can be built into PHP. The trick to her method is sending things with the right header.
We can't send post fields, because we want to send JSON, not pretend to be a form (the merits of an API which accepts POST requests with data in form-format is an interesting debate). Instead, we create the correct JSON data, set that as the body of the POST request, and also set the headers correctly so that the server that receives this request will understand what we sent.
She includes a code example (about ten lines) showing the POSTing process that sets up options using curl's curl_setopt. Be sure to set up the headers to send as "application/json" - that's the trick to letting the remote end know the format.
voice your opinion now!
post data tutorial json curl curlsetopt
Lorna Mitchell's Blog:
by Chris Cornutt July 28, 2011 @ 12:03:02
Lorna Mitchell has a quick post to her blog today showing how you can use a simple curl call from PHP to shorten urls with bit.ly and pull back the result.
I've been looking around for a really simple API that would be a nice place to get started using web services from PHP - and I realised that bit.ly actually fits the bill really well. They have straightforward api docs on google code, and it's also a pretty simple function!
Her code is about three lines consisting of a curl_init call to the bit.ly server with the URL, a curl_setopt to tell it to return the information and a curl_exec to execute. The result is a JSON string easily decoded with a "url" parameter containing the newly minted short URL. She also briefly mentions some of the other features of the bit.ly API including reverse translation and bundling of links.
voice your opinion now!
bitly url shortening api curl example
Philip Norton's Blog: Netscape HTTP Cooke File Parser In PHP
by Chris Cornutt June 30, 2011 @ 09:09:00
Philip Norton has shared a script he's created in a new post today that lets you read from a Netscape-formatted cookie file (as outputted from a curl request).
This file is generated by PHP when it runs CURL (with the appropriate options enabled) and can be used in subsequent CURL calls. This file can be read to see what cookies where created after CURL has finished running. As an example, this is the sort of file that might be created during a typical CURL call.
The file is structured, plain-text content with information on the domain, path, security, name and expiration details of each cookie. His script parses out these details and pushes them into a basic array, prime for searching and sorting (and reuse) in your application.
voice your opinion now!
netscape http cookie file curl output
PHPBuilder.com: PHP Multithreading with cURL
by Chris Cornutt June 10, 2011 @ 11:08:58
On PHPBuilder.com Jason Gilmore has posted a new tutorial about how to handle a more true version of multi-threading (non-native, of course) in a PHP application making HTTP requests. His method uses cURL, the popular extension that make working with socket connections a lot simpler.
This article explains an alternative solution that consists of sending multiple HTTP requests to the same Web server on which PHP is running. Each HTTP request triggers the execution of a different task. Many requests can be run at the same time without having to wait for each one to finish. [...] As you may know, PHP has no native support for multithreading like Java, but using the cURL extension makes multithreading possible in PHP.
He introduces cURL a bit, talking about the protocols it supports and how to check and see if you have the extension installed. He then walks through a sample connection, calling curl_setopt and curl_exec to fetch a remote page from a website. The real fun comes in when you use the curl_multi_add_handle and curl_multi_exec methods to run more than one request in parallel.
voice your opinion now!
multithreading tutorial curl http request
Martin Sik's Blog: How to "steal" Google's "did you mean" feature
by Chris Cornutt May 19, 2011 @ 12:49:32
In a a new tutorial posted on his blog Martin Sik shows you how to "steal" the "did you mean..." functionality that Google's sites currently offer. His example uses cURL to get the current Google request URLs and fetch the associated results.
I really like Google and the classic "did you mean" feature is really great, unfortunately when I wanted to implement it into my project a realized that it's not provided by any of Google's APIs. [...] I believe for most developers [having a large dictionary and extend the dictionary when new terms are available] are unachievable. And so it's for me. So I was thinking if I can bypass these drawbacks and let Google do all the job for me.
The source code is included with the post showing two methods - fetching a "did you mean" block to parse or how a term is attached to a Google URL and the results are returned in JSON and parsed for display. Obviously, this is an external dependency you could consider if you put it into your application, but it can be quite a powerful tool in the right situations.
voice your opinion now!
google suggestion feature curl url json
PHPRiot.com: Translating Text Using the Google Translate API and PHP, JSON and cURL
by Chris Cornutt May 06, 2011 @ 08:45:04
On PHPRiot.com there's a new tutorial showing you how to use the Google Translate service to translate the text of your website into any language they support. They interface with it using a cURL connection and JSON messaging.
Google Translate is a service from Google that you can use to translate text or HTML from one language to another. One of the great features of this service is that they now offer an API to let you programmatically translate text. In this article I will show you how to interact with the Google Translate API. Initially, the Google Translate API was available only via JavaScript. This has now changed, as version 2 offers a REST interface which returns translations in JSON format.
They talk about the input parameters you can give the service, the enforcement of query limits and how to handle the results that are returned. The response message is, by default, in JSON so a simple call to json_decode should be all that's needed. They've also included a sample class you can drop in and use for your translation needs (as well as sample usage code).
voice your opinion now!
google translate api json curl tutorial language
|
Community Events
Don't see your event here? Let us know!
|