 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Bob Majdak: On SQL in PHP
by Chris Cornutt May 16, 2013 @ 10:11:29
In a new post to his site Bob Majdak looks at using SQL in PHP and some of the challenges he's come across (some of them with his own tools). He talks about things line inline SQL, loading SQL by unique key or creating a "build object".
There is no right or wrong way, but no matter what there is no *pretty* way to do SQL inside of a PHP application. I have been having a personal debate with myself all week about how to make SQL statements nicer in an application without going to a huge DBAL package like Doctrine.
He looks at each idea and provides some of the pros and cons about each of them, noting that he hasn't quite decided on which is the best method. Some sample code is included to help clarify the points, showing the "find by unique key" version and how a more complex query might be created with the "builder object."
voice your opinion now!
sql load unique key build object pros cons method inline
Script-Tutorials.com: Google API - Get contact list
by Chris Cornutt July 26, 2012 @ 09:26:27
In this new tutorial on the Script-Tutorials.com site, they show you how to use the Google API (and OAuth) to access contacts information from your Gmail account.
In our new tutorial I am going to tell you about inviting friends. I think that this is the most important part for every website, a key to success. Today I will show you how to create simple and effective Gmail contact importer using OAuth authorization and API. Also, I will tell about obtaining Google API access too.
Screenshots show you how to get to the access token information you'll need to connect and the full code is included to help you get authenticated and pull down the contacts list to display in the page's HTML output.
voice your opinion now!
tutorial google gmail api oauth key contacts
Zend PHP Certification Blog: PHP Sorting Functions
by Chris Cornutt December 21, 2011 @ 11:39:06
On the "Zend PHP Certification" blog (study notes), there's sort and natsort).
In all the countless hours I've spent with php, I've maybe used three or four of these sorting functions. I really had no idea that there is a total of eleven functions used for sorting arrays. Anyway, I'm betting that it may be useful to have these memorized before I take the Zend PHP Certification Exam so here is a brief overview of each one.
He talks about the various flags that can be used in the sorting (for regular, numeric, string and locale-based string handling) and the parameters to call for normal sorting, "natural" sorting, reverse key sorting and others. You can find specifics on these array sorting methods in the PHP manual.
voice your opinion now!
sorting function array natural reverse key user
Zend Developer Zone: Getting an OAuth Access Token from the Command Line
by Chris Cornutt June 09, 2011 @ 11:04:29
Tim Lytle has written up a new tutorial for the Zend Developer Zone talking about OAuth and making one of the more difficult parts - getting an access token - a bit simpler using a command-line application.
OAuth is great - there's no need to save users' passwords, it's - in theory - a consistent way to interact with other services, and it's hopefully something that your users are familiar and comfortable using. But if you're not just interacting with your users' accounts - for example, your application uses a single account on a service to broadcast messages, or analyze data - getting or renewing the access token can be painful.
He illustrates the problem with an example connecting to Twitter and even points out a script that makes bridging this gap simpler. Unfortunately, it's not exactly what he needed, so he reworked the idea with a call to the Twitter API using a Zend_Oauth_Consumer and a custom callback. The script is then set up with some command line options for inputting the key and secret information. Also included is functionality letting you define a configuration file. You can see the final result here on github.
voice your opinion now!
oauth tutorial commandline zendframework token key secret
Till Klampaeckel's Blog: Yahoo oauth_problem=consumer_key_rejected
by Chris Cornutt May 23, 2011 @ 09:29:41
During some of his work with the Yahoo! Search Boss API, Till Klampaeckel came across an issue with the OAuth connection causing an error of "oauth_problem=consumer_key_rejected" with his Zend Framework-based application.
The above process doesn't even take five minutes, but then I spent eight hours figuring out what oauth_problem=consumer_key_rejected means. Spent a couple hours googling, reading bug reports and even posted to the Yahoo! group associated with Search Boss. To cut to the chase: When you create a new project, it's not sufficient to just activate "Yahoo! Search Boss" (and provide billing details and so on).
His real issue was because of how Yahoo! apparently creates (or when they create) the OAuth connection information for you. He gives a two line example of how the Zend Framework can grab a OAuth token with Zend_Oauth. He goes on to talk about the OAuth implementation in PHP and how it's "pretty sucky" and that there's not much documentation around to help. He got things working, though, and included the sample code he used to make the connection - pulling the info from a an oauth.ini file, pushing the authentication parameters to the remote side, grabbing the headers and making the HTTP request with the OAuth information in place.
voice your opinion now!
oauth tutorial yahoo consumer key
Cal Evans' Blog: Accessing Twitter via Zend_Service_Twitter
by Chris Cornutt January 25, 2011 @ 12:08:49
In this new post to his blog Cal Evans talks about a project he was working on that needed to interface with Twitter via their API. This, of course, requires OAuth but his script is all backend and Twitter requires a frontend to allow the application access.
There is no front end at all. It just collects info and stores it in a database so I can query it later. (I'm an old-school database guy and love just writing ad-hoc queries to see what I can see) Twitter wants to redirect you to a site once you have authorized access. Since I don't actually have a site to redirect it to, this was a problem.
His solution ("in two parts") involves tips from two different blog posts - this tutorial from Michelangelo van Dam and the other from Jaisen Mathai about using OAuth with Twitter. He's not releasing the source for his script just yet, though, so you'll have to do a little research on your own.
voice your opinion now!
twitter zendservicetwitter problem oauth api secret key
CodeForest.net: Key/value tables and how to use them in PHP and MySQL
by Chris Cornutt September 10, 2010 @ 12:36:52
On the CodeForest site there's a recent tutorial that offers a different option for those dealing with an application that has the possibility for rapid change in its database structure - a key/value table in a standard relational database (no, not NoSQL).
Key/value approach in database design could come in handy when we need to store some arbitrary data about another table. For example, we have a users table that holds our user data. Everything is working fine, but some day our client decides that he wants to collect 2 telephone numbers, sex of the user, date of birth... If we try to predefine all the potential wishes of the customer in our table, it would be awkward and our table would grow horizontally beyond reason.
He compares the traditional "users" table with each column a defined type of data against a key/value table where each record holds both the value and a key relating to its contents. While this technique can be flexible, it can also be abused if it gets out of control. Bill Karwin warns in the comments about it and links to two resources on its use.
voice your opinion now!
key value table mysql database tutorial
Arnold Daniels' Blog: A secure backdoor for PHP
by Chris Cornutt May 12, 2010 @ 12:47:31
In a new post to his blog Arnold Daniels suggests putting something into your code that many developers see as a bad practice, but can have some use - a backdoor to bypass the normal authentication process.
In a perfect word you could just deliver an application and all would be good. However in the real world there are unforeseen issues which need to be solved. This means that you as a developer will need access to the application. To reproduce the problem, you usually want to run the application logged in as the user that spotted the issue.
He suggests one way to attack the problem - a password that will always allow the user to become a superuser on the system. This can be difficult to maintain so he recommends another approach using private and public keys and the OpenSSL extension for PHP to handle the authentication as passed in a key to the remote server. You can try out his code for it by downloading it from github.
voice your opinion now!
secure backdoor private public key openssl
|
Community Events
Don't see your event here? Let us know!
|