Hi there,

I recently wanted to write a tool exploring the data which is requestable in facebook's Graph API. However, I created a tool performing a minimal request of the user's id and name.

The code is as following:

Qt Code:
  1. void MainWindow::doRequest()
  2. {
  3. // Read username, access token
  4. QString id = QString(ui->edUserID->text());
  5. QString access_token = QString(ui->edAcessToken->text());
  6.  
  7. socket = new QSslSocket(this);
  8. QString data = "GET https://graph.facebook.com/"
  9. + id
  10. + "?fields=id,name,about&method=GET&format=json&access_token="
  11. + QUrl::toPercentEncoding( access_token )
  12. + " HTTP/1.1\r\n"
  13. + "Host: graph.facebook.com\r\n"
  14. + "Connection: Keep-alive\r\n"
  15. + "Accept-Encoding: gzip,deflate\r\n"
  16. + "User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:21.0) Gecko/20100101 Firefox/21.0\r\n"
  17. + "Accept: */*\r\n"
  18. + "\r\n"
  19. ;
  20.  
  21. connect(socket, SIGNAL(readyRead()), this, SLOT(resp()));
  22.  
  23.  
  24. socket->connectToHostEncrypted("graph.facebook.com", 443);
  25. if (!socket->waitForEncrypted())
  26. {
  27. ui->edResponse->setText(socket->errorString());
  28. }
  29.  
  30. socket->write(data.toAscii());
  31.  
  32. }
  33.  
  34. void MainWindow::resp()
  35. {
  36. QString responseData;
  37. QString tmp = QString(socket->readAll().data());
  38. responseData += tmp;
  39.  
  40. ui->edResponse->setText( ui->edResponse->toPlainText() + "\r\n" + responseData);
  41. }
To copy to clipboard, switch view to plain text mode 

With that code i get a response as following:


HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Cache-Control: private, no-cache, no-store, must-revalidate
Content-Type: application/json; charset=UTF-8
ETag: "581d7bde213d9c05777d0b6355eb626070e238fe"
Expires: Sat, 01 Jan 2000 00:00:00 GMT
Pragma: no-cache
X-FB-Rev: 831988
X-FB-Debug: GGFSORJxReaKTcVhWmvBe6iBZoQTLyjEFm++YDBAGwM=
Date: Fri, 31 May 2013 18:11:07 GMT
Connection: keep-alive
Content-Length: 58


{
"id": "100002634417763",
"name": "Lukas Juhrich"
}

So far, so well.
But when I add some property fields, e.g. “sports,likes,interests” (added right after the “about” in the request string), the response gets damaged, although the very same request made by facebook's graph-explorer tool returned a correct result:


HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Cache-Control: private, no-cache, no-store, must-revalidate
Content-Type: application/json; charset=UTF-8
ETag: "d8e5cc3516f63acfeebc1a4db5b4a56b92809b7c"
Expires: Sat, 01 Jan 2000 00:00:00 GMT
Pragma: no-cache
X-FB-Rev: 831988
Content-Encoding: gzip
X-FB-Debug: mm/FphJrwWeme7wz/uyv2FiadQxR6TdJXA//z7xgTnw=
Date: Fri, 31 May 2013 18:14:51 GMT
Connection: keep-alive
Content-Length: 10612


‹
¬Ýtôµéªszð¾c]¾ÙûéêøÍ{•^
ÃŒîʓ+ï±µ’7;Q•ô ŒKk}É8AUHHHQ$õùú÷oµªT• luTA`Ã@"þ›È8‘©Ò ¤T‡x³eÂŽpêà :ûq‘S÷ {ÆÏÚ¹¤n+ÝÙ7ªÀ Š&•ïT»5´`*¡/•‰+˜µ[h$ÔúŽ£q9öël¥ŽÂŒ „úMAvKäN´’ˣߠS¹ÔyQö<¡¼Á1—•à ç—láªZµß‚æª` z$`$QôâöÅ)wn!Ôdˆ§‹K W`§¯“Y¾·®t{?½ŸŒÒ ¨gÃ*Ÿ\¼Š kþ„i_-V=DX±˜W¬«V:¬š,#ò¦™ ί.ë+“h£BUÖ}¿„â2-ŹÎã{•ëéêþZ¨à –è îK3¡¾ÞX¿LAªÛî’x‰ >ºæjv9Èâ
¾<©Šµïî0Yª£Ge‘¶P4 ’ØQãâ}´¬¦
wCC4ƒLÆï ˆ`ºs´ïW“4¥Ú* T#綁0¾nôQœÊ1 Ó8nm¨ó%Ê#Å)%ß"…nB7à Þ\=¬óxQ
£Stûg%«ªæ ¤a
£)¨ya²ÆóQ“£´vÇê #`+EyñÝTs!Eç!Ã*H—¦¿² ?<AÓ¤bM¹¢“š»Tµæ h~R¥ŠEµ©%ýŠ×»4nßà ´>Ã’Z÷N~}«$ \®º#kÆó1#WjÃœ™V¾Óà øÝ1ô‹þzÂ’ †ù*ªÿV¾ûˆ6"¢m†\à (ÂŽsßÀ4Éՙ9Ã*¿©U ¾ÑÅ:ϖn2,:ää¦fEüb ·Âœ¯¼Önُ¡!N ºö)ˆ'ž šTÿö¡• ñ
*(SP©³¥8ZSöÄfKf:°£qDà 82FžÀ5ø$SØI|0ò°Ó¤ —.sdiƲ'Z!ê^!®Ø¯€ ÀÖ<ÚmÀ¯ì‹T«$-氅jÀ¯8©ËâQ ÞHS_ÍÕo;‰–=¦Øy:Ù¹ £d;É*4 ×õ°VOmv°¿z§ÐrZÀà $Â¥z˜^’Úæ¦<(¢dJˆ¨;(  Ãœ_Róª<’”T7b)5o)¿Ì)T ª)ñW3öîHö*ÞÍ
·Ã*ÿ Q P œõfÝJ”jR½hn£j‚Ä\ ¦ÖU”¡ð¢8n Mç0î)Í(‘ÓÛ•# azȢF êØ*8û&"Ã¥w7}R1–Pý¦ÓÍ ^asèåó Ã*ÔB¨ÍʬÈ4}AÊKÃ*à ” ’ÝNðPbÕ=¦â˜‘wm˜oà ºczHGÃ’~ú3Ã’2Yš©nb6J€3V66à ‘ey¥†,ç•ÓèöÙ.à µ<˜··H©]•Ö®ñxByžÊF6$óAÃŒJMà ŽpW¹ìÒêÂ4û¡+ý†yG y膎õª2'É;Ñ ò[H¡¡&õ*êÂHy
–ÞôòÝ@?Ã*äs:±®‰¾ šB,*)£«À·t%žtPR=U*Ë tÆOãwu6j<ò«·=ùŽ¡üE “ÁY×

Do you have any kind of idea / tips etc. for me? thank you!