Disable URL encoding of querystring parameters

6,109 views
Skip to first unread message

Chris Noden

unread,
Oct 23, 2013, 6:09:08 AM10/23/13
to guz...@googlegroups.com
$client = new Client('https://graph.facebook.com/');

$request = $client->get(
    sprintf(
        '/oauth/access_token?client_id=%s&client_secret=%s&redirect_uri=%s&code=%s',
        $this->app_id,
        $this->app_secret,
        $redirect_uri,
        $code
    )
);
var_dump($request->getUrl());

The output looks like:
Message has been deleted

Michael Stramel

unread,
Oct 23, 2013, 2:27:06 PM10/23/13
to guz...@googlegroups.com
Also, you may want to look into URI Templates instead of sprintf and into the OAuth plugin. Just a suggestion though.

Docs for URI Templates can be found here: 


Chris Noden

unread,
Nov 14, 2013, 12:20:05 PM11/14/13
to guz...@googlegroups.com
I'm not sure how this should work. eg:

        $query = $request->getQuery();
        $query->useUrlEncoding(false);

But then how do you set $query back into the $request ? If I follow this with: $request->send(); then I still get url-encoded queries being posted.

On Wednesday, October 23, 2013 7:12:47 PM UTC+1, Michael Stramel wrote:
Hey Chris,


By using the request's query using $request->getQuery(then  $query->useUrlEncoding(false); you can disable UrlEncoding.

Hope this helps.


On Wednesday, October 23, 2013 5:09:08 AM UTC-5, Chris Noden wrote:

Chris Noden

unread,
Nov 14, 2013, 12:27:49 PM11/14/13
to guz...@googlegroups.com
Which also reminds me, how do I stop elements in the form (postBody) from being encoded ? Please include an example that works for you from start to finish using the HTTP Client class with get() and post() methods through to the send() call.

Thanks

Chris

Michael Stramel

unread,
Dec 10, 2013, 5:07:32 PM12/10/13
to guz...@googlegroups.com
I believe that setting $query->useUrlEncoding(false); will set it in the $request.

George Casinder

unread,
Jul 23, 2014, 2:57:29 PM7/23/14
to guz...@googlegroups.com, guz...@googlegroups.com

Is this for Guzzle 4 too? I get:

Fatal error: Call to undefined method GuzzleHttp\Message\Response::getQuery() .

On Wednesday, December 11, 2013 12:07:32 AM UTC+2, Michael Stramel wrote:
I believe that setting $query->useUrlEncoding(false); will set it in the $request.

On Thursday, November 14, 2013 11:20:05 AM UTC-6, Chris Noden wrote:
I'm not sure how this should work. eg:

        $query = $request->getQuery();
        $query->useUrlEncoding(false);

But then how do you set $query back into the $request ? If I follow this with: $request->send(); then I still get url-encoded queries being posted.

On Wednesday, October 23, 2013 7:12:47 PM UTC+1, Michael Stramel wrote:
By using the request's query using $request->getQuery(then  $query->useUrlEncoding(false);<span style="font-family:Consolas,Monaco,Menlo,'Courier New',monospace;font-size:14px;line
...

adamw...@elearning247.com

unread,
Aug 20, 2014, 7:23:06 AM8/20/14
to guz...@googlegroups.com

I'm having this problem here too, any help much appreciated.

I get: undefined method GuzzleHttp\Query::useUrlEncoding()

and if I use $request->getQuery()->setEncodingType(false); I dont know how to get that back into the request.

Thanks

Michael Stramel

unread,
Oct 23, 2013, 2:12:47 PM10/23/13
to guz...@googlegroups.com
By using the request's query using $request->getQuery(then  $query->useUrlEncoding(false); you can disable UrlEncoding.

Hope this helps.


On Wednesday, October 23, 2013 5:09:08 AM UTC-5, Chris Noden wrote:
Reply all
Reply to author
Forward
Message has been deleted
0 new messages