Jeśli jesteś właścicielem tej strony, możesz wyłączyć reklamę poniżej zmieniając pakiet na PRO lub VIP w panelu naszego hostingu już od 4zł!

Archive for Marzec, 2012

Lorna Mitchell’s Blog: Using OAuth2 for Google APIs with PHP

Lorna Mitchell’s Blog: Using OAuth2 for Google APIs with PHP

Lorna Mitchell has a new post to her blog today showing how to use the functionality provided by the pecl_http extension to make an OAuth2 connection to Google.

I’ve written about Google and OAuth before, but that was OAuth v1.0, and they are introducing OAuth2 for their newer APIs; in this example I was identifying myself in order to use the Google Plus API. [...] OAuth 2 doesn’t need an extension or any particular library as it doesn’t have the signing component that OAuth 1 had, and OAuth 2 also has fewer round trips. It does require SSL however, because the requests are in the clear.

She includes some code snippets with an example of a connection – making a request to the remote HTTPS resource, adding some parameters to the URL (including the response type, your client ID and a redirect url). The response then contains the “code” value you’ll need to make the second request to fetch the access token you’ll need on future requests. You can find out more about the interface she’s accessing in these docs about the Google Plus API.

Source: http://www.phpdeveloper.org/news/17752

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Lorna Mitchell’s Blog: Using OAuth2 for Google APIs with PHP

Lorna Mitchell’s Blog: Using OAuth2 for Google APIs with PHP

Lorna Mitchell has a new post to her blog today showing how to use the functionality provided by the pecl_http extension to make an OAuth2 connection to Google.

I’ve written about Google and OAuth before, but that was OAuth v1.0, and they are introducing OAuth2 for their newer APIs; in this example I was identifying myself in order to use the Google Plus API. [...] OAuth 2 doesn’t need an extension or any particular library as it doesn’t have the signing component that OAuth 1 had, and OAuth 2 also has fewer round trips. It does require SSL however, because the requests are in the clear.

She includes some code snippets with an example of a connection – making a request to the remote HTTPS resource, adding some parameters to the URL (including the response type, your client ID and a redirect url). The response then contains the “code” value you’ll need to make the second request to fetch the access token you’ll need on future requests. You can find out more about the interface she’s accessing in these docs about the Google Plus API.

Source: http://www.phpdeveloper.org/news/17752

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Phil Sturgeon’s Blog: Hijacking Headers to Force Downloads

Phil Sturgeon’s Blog: Hijacking Headers to Force Downloads

Phil Sturgeon shows how you can hijack headers in his latest post to force a download to the client (even on a hosted service like PagodaBox).

The question [I posed on Twitter] was: “How to force a download of any file of any type, not on your server, without Apache tweaking? Images are displaying and need em to download.” Essentially, I wanted to be able to link to a file that was not on the server in question and anywhere in the world, which could be of any size, any media type and could be potentially very high traffic.

Answers varied from using readfile to just letting the browser handle it. None of the responses were quick right until he came across one that recommended some settings in an .htaccess file. It uses mod_rewrite (Apache) to redirect the user to a new resource while adding a “Content-Disposition” header in the process (of “attachment”).

Source: http://www.phpdeveloper.org/news/17751

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Phil Sturgeon’s Blog: Hijacking Headers to Force Downloads

Phil Sturgeon’s Blog: Hijacking Headers to Force Downloads

Phil Sturgeon shows how you can hijack headers in his latest post to force a download to the client (even on a hosted service like PagodaBox).

The question [I posed on Twitter] was: “How to force a download of any file of any type, not on your server, without Apache tweaking? Images are displaying and need em to download.” Essentially, I wanted to be able to link to a file that was not on the server in question and anywhere in the world, which could be of any size, any media type and could be potentially very high traffic.

Answers varied from using readfile to just letting the browser handle it. None of the responses were quick right until he came across one that recommended some settings in an .htaccess file. It uses mod_rewrite (Apache) to redirect the user to a new resource while adding a “Content-Disposition” header in the process (of “attachment”).

Source: http://www.phpdeveloper.org/news/17751

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Community News: Win a phpDay/jsDay 2012 Ticket

Community News: Win a phpDay/jsDay 2012 Ticket

The jsDay/phpDay organizers have announced a contest to win a free ticket to this year’s event(s), one for each conference:

GrUSP is organising a tweet contest and its prizes will be two tickets, one for each conference. The contest will start today (March 29th) at 1pm CEST and will end April 1st at 7pm CEST.

Anyone can enter – all you have to do is tweet a post with a few things: the “#grsup” hashtag, a mention of the twitter accounts for the events, a link to the conference site and something about the event. Be sure and get those tweets posted before April 1st a 9am CEST – they’ll pick the winners soon after! (Oh and multiple entries are accepted so the more you tweet, the better your chances!)

Source: http://www.phpdeveloper.org/news/17750

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Community News: Win a phpDay/jsDay 2012 Ticket

Community News: Win a phpDay/jsDay 2012 Ticket

The jsDay/phpDay organizers have announced a contest to win a free ticket to this year’s event(s), one for each conference:

GrUSP is organising a tweet contest and its prizes will be two tickets, one for each conference. The contest will start today (March 29th) at 1pm CEST and will end April 1st at 7pm CEST.

Anyone can enter – all you have to do is tweet a post with a few things: the “#grsup” hashtag, a mention of the twitter accounts for the events, a link to the conference site and something about the event. Be sure and get those tweets posted before April 1st a 9am CEST – they’ll pick the winners soon after! (Oh and multiple entries are accepted so the more you tweet, the better your chances!)

Source: http://www.phpdeveloper.org/news/17750

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Nikita Popov’s Blog: Understanding PHP’s internal array implementation (Part 4)

Nikita Popov’s Blog: Understanding PHP’s internal array implementation (Part 4)

Nikita Popov has posted the fourth part of the “PHP’s Source Code for PHP Developers” series he and Anthony Ferrara have been posting. In this latest article in the series, Nikita looks specifically at PHP’s array implementation and how it’s handed “behind the scenes”.

Welcome back to the fourth part of the “PHP’s Source Code for PHP Developers” series, in which we’ll cover how PHP arrays are internally represented and used throughout the code base.

He starts with an obvious foundation: “everything’s a hash table” (even properties, classes and yes, arrays). He describes what a hash table is and talks about two of the most commonly used versions of it in the PHP source – HashTable and Bucket. He gets into their usage a bit and compares this to the corresponding PHP code that uses a standard array.

Source: http://www.phpdeveloper.org/news/17749

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Nikita Popov’s Blog: Understanding PHP’s internal array implementation (Part 4)

Nikita Popov’s Blog: Understanding PHP’s internal array implementation (Part 4)

Nikita Popov has posted the fourth part of the “PHP’s Source Code for PHP Developers” series he and Anthony Ferrara have been posting. In this latest article in the series, Nikita looks specifically at PHP’s array implementation and how it’s handed “behind the scenes”.

Welcome back to the fourth part of the “PHP’s Source Code for PHP Developers” series, in which we’ll cover how PHP arrays are internally represented and used throughout the code base.

He starts with an obvious foundation: “everything’s a hash table” (even properties, classes and yes, arrays). He describes what a hash table is and talks about two of the most commonly used versions of it in the PHP source – HashTable and Bucket. He gets into their usage a bit and compares this to the corresponding PHP code that uses a standard array.

Source: http://www.phpdeveloper.org/news/17749

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Rob Allen’s Blog: Returning JSON from a ZF2 controller action

Rob Allen’s Blog: Returning JSON from a ZF2 controller action

In a new post to his blog Rob Allen shows how you can return JSON data directly back from a controller in a Zend Framework 2 application.

The new view layer in Zend Framework 2 can be set up to return JSON rather than rendered HTML relatively easily. [...] Firstly we need to set up the view’s JsonStrategy to check to a situation when returning JSON is required and then to render out JSON for us.

This “JsonStrategy” does some of the hard work for you – detecting when the client is requesting a JSON response and looking at the data coming into the view to see if it’s JSON. He shows how to implement it in a sample module using the “onBootstrap” module and how to force a return of the JsonModel even when JSON isn’t requested (useful for a consistent interface).

Source: http://www.phpdeveloper.org/news/17748

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Rob Allen’s Blog: Returning JSON from a ZF2 controller action

Rob Allen’s Blog: Returning JSON from a ZF2 controller action

In a new post to his blog Rob Allen shows how you can return JSON data directly back from a controller in a Zend Framework 2 application.

The new view layer in Zend Framework 2 can be set up to return JSON rather than rendered HTML relatively easily. [...] Firstly we need to set up the view’s JsonStrategy to check to a situation when returning JSON is required and then to render out JSON for us.

This “JsonStrategy” does some of the hard work for you – detecting when the client is requesting a JSON response and looking at the data coming into the view to see if it’s JSON. He shows how to implement it in a sample module using the “onBootstrap” module and how to force a return of the JsonModel even when JSON isn’t requested (useful for a consistent interface).

Source: http://www.phpdeveloper.org/news/17748

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>