Trying to use curl to do a GET, value being sent is allows null


I'm trying to use curl to do a simple GET with one parameter called redirect_uri. The php file that gets called prints out a empty string for $_GET["redirect_uri"] it shows red= and it seems like nothing is being sent. code to do the get

//Get code from login and display it $ch = curl_init(); $url = 'http://www.besttechsolutions.biz/projects/facebook/testget.php'; //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_GET,1); curl_setopt($ch,CURLOPT_GETFIELDS,"redirect_uri=my return url"); //execute post print "new reply 2 <br>"; $result = curl_exec($ch); print $result; // print "<br> <br>"; // print $fields_string; die("hello");

the testget.php file

<?php print "red-"; print $_GET["redirect_uri"]; ?>


This is how I usually do get requests, hopefully it will help you:

// create curl resource $ch = curl_init(); //return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Follow redirects curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Set maximum redirects curl_setopt($ch, CURLOPT_MAXREDIRS, 5); // Allow a max of 5 seconds. curl_setopt($ch, CURLOPT_TIMEOUT, 5); // set url if( count($params) > 0 ) { $query = http_build_query($params); curl_setopt($ch, CURLOPT_URL, "$url?$query"); } else { curl_setopt($ch, CURLOPT_URL, $url); } // $output contains the output string $output = curl_exec($ch); // Check for errors and such. $info = curl_getinfo($ch); $errno = curl_errno($ch); if( $output === false || $errno != 0 ) { // Do error checking } else if($info['http_code'] != 200) { // Got a non-200 error code. // Do more error checking } // close curl resource to free up system resources curl_close($ch); return $output;

In this code, the $params could be an array where the key is the name, and the value is the value.


  • OpenSSL-1.0.2j installation on Windows 10 - fatal error C1083: Cannot open include file: 'lmsta
  • Tile map collide not working as expected in Javascript
  • How to mock bean and avoiding NoUniqueBeanDefinitionException
  • Transform all Array Keys with Values from another Array
  • Birt script behaves differently via web viewer
  • Why is this piece of Javascript code so slow?
  • cURL not working while fetching Google API data
  • Laravel 5.1 csrftoken curl from paypal
  • Is it possilbe to automatically submit a php form
  • How do I use cURL & PHP to spoof the referrer?
  • Reinitialise existing jQuery flexslider with new options
  • How to Update model and database with code first approach in Asp.net MVC
  • Should I optimize around reads or CPU time in Google App Engine
  • Interpreting STRACE output - pipes and forks
  • rspec simple example getting error on request variable in integration test
  • Do I need to reset a Perl hash index?
  • Is there a javascript serializer for JSON.Net?
  • Ajax jQuery multiple calls at the same time - long wait for answer and not able to cancel
  • How do I fake an specific browser client when using Java's Net library?
  • Date difference with leap year
  • VS2008 Enable C++ Exception with SEH
  • angularjs unit test when to use $rootScope.$new()
  • Volusion's generic SQL folder, functionality
  • Menu Color Fade on Hover with Jquery
  • Where to put my custom functions in Wordpress?
  • How to limit post in wp_query
  • Hazelcast - OperationTimeoutException
  • How to make Safari send if-modified-since header?
  • Adding custom controls to a full screen movie
  • Why winpcap requires both .lib and .dll to run?
  • Buffer size for converting unsigned long to string
  • Free memory of cv::Mat loaded using FileStorage API
  • How to set the response of a form post action to a iframe source?
  • Memory offsets in inline assembly
  • Change div Background jquery
  • Turn off referential integrity in Derby? is it possible?
  • Qt: Run a script BEFORE make
  • reshape alternating columns in less time and using less memory
  • Binding checkboxes to object values in AngularJs
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize