I'm trying to get the details from this example (i created the code right now).
But i'm very... confused... how can i get the details of the link, then separate and send to my MYSQL database..
<?php
$ch = curl_init();
$url = "https://reqres.in/api/users?page=2";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$resp = curl_exec($ch);
if($e = curl_error($ch)) {
echo $e;
}
else {
$decoded = json_decode($resp, true);
//print_r($decoded);
foreach($decoded as $key => $item) {
$array = array(
'id' => ,
'email' => ,
'first_name' => ,
'last_name' => ,
);
print_r($array);
}
}
curl_close($ch);
?>
If you call the url in your browser then you will see that the result array is present in the data field.
You may check this by printing the whole result:
print_r($decoded);
So if you like to print_r the results it should be simply
print_r($decoded['data']);
If you like to store it in your database you may walk through the array and store each item
foreach($decoded['data'] as $item) {
storeItem($item);
}
To make this work you should implement the storeItem function which accepts the array $item and stores it into your database. There are various tutorials about doing that.
Related
This is my first time using web service. My PHP server get the json data from .net server where it is encoded to base64.
The problem now is, i failed to read each attribute inside the data:
Array ( [JSONDataResult] => {"file":"iVBORw0KGgoAAAANSUhEUgAAALUAAAEZCAYAAADR+mSIAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABhuSURBVHhe7ZiBcuM4smz3\/3\/6PkrPjCgfppBMFWB53DgRx2whs4raMWJ7dv938H8\/KVGdjkR1qrNx+13ehftTU9w889V+vVOHqySq05GoTnU2br\/Lu3B\/aoqbZ77ar3fqcJVEdToS1anOxu13eRfuT01x88xX+\/VOHa6SqE5HojrV2bj9Lu\/C\/akpbp75ar\/eeT2cids\/O6cp6Xzad6zeR1PS+bSfovYfz+vhTNz+2TlNSefTvmP1PpqSzqf9FLX\/eF4PZ+L2z85pSjqf9h2r99GUdD7tp6j9x\/N6OBO3f3ZOU9L5tO9YvY+mpPNpP0XtP57XwwpzJ3E5Wd0n6fyn+93c4eZdTlyfuZOo\/HheDyvMncTlZHWfpPOf7ndzh5t3OXF95k6i8uN5Paw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WpklH+KlO9k1F2os5ORtnmj3HncqQXiIy6NRu9d5SdqLOTUbb5Y9y5HOkFqox67j31s+s+UGcno2zzx7hzOd65QKdklD0Y5a+yes58lG02m81ms\/kI6q\/jevYq33+Nb34t6aUeZZvNr6BzqTebX8njkipP6p9P1Nlm82twl\/bVBd4Xe\/NrefdSP9gXe\/MrSS\/1KNtsfgXppX7wONsXerPZbDabTYPRv06cmcpH2QOV1RmVP1BZPWP24NX5g3ezzX+U85f56hdeqZ9H2cnj7E6v4vKT2hu9491s8we48wsddV5dkFfnilFWcTvr53ezzR\/gzi9UXYJTcp6NZpKsorJXc6PPrrv5j+N+oUn+6s+KUVfN3jlTn6snqrf5Q4x+oXd+2bws9BU1Y0\/N3TlTnZOaJXOb\/yCvfqF3z9\/t1c9JtzKr92pu8x\/j8YukJ6PswavzispGcy57xau5V+cnLt9sNpvNZrPZbDabzWaz2Ww2m81M\/ve\/\/wclQxXDBQHQjQAAAABJRU5ErkJggg==","fileSize":"8484","returnCode":"0"} )
There are 3 columns:
file
fileSize
returnCode
I have tried to get data using Object, Array or json but always failed.
//$json = json_decode($data, true); //array
//$json = json_decode($data); //object
//echo $result; //JSONDataResult
Below is one of the FAILED method. The full process coding:
<?php
if (isset($_GET['submit'])) {
$project_code = $_GET['project_code'];
$url = "http://1.2.3.4/to/file/process";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($curl, curlopt_httpheader, array ("Content-type:application/json"));
$result = curl_exec($curl);
curl_close($curl);
$data = file_get_contents($url);
$json = json_decode($data, true); //array
//$json = json_decode($data); //object
//echo $result; //JSONDataResult
//print_r($json);
foreach ($json as $key => $value) {
if (!is_array($value)) {
//always goes here
echo "not array: ".$key . '=>' . $value . '<br/>';
} else {
foreach ($value as $key => $val) {
echo "is array: ".$key . '=>' . $val . '<br/>';
}
}
}
}
?>
Guys help me to read the content. I do not mind using which method as long as i can read each column inside the content. Many-many thank you.
[jangankecamsaya]
Assuming the data you posted in the question is the output of print_r($json);, it is clear that $json is an array that contains only one value (the big JSON) associated to the key JSONDataResult. It basically looks like this:
$json = array('JSONDataResult' => '{"file":"iVBORw0KGgoAAAANSUhEUgAAALUAAAEZCAYAAADR+mSIAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABhuSURBVHhe7ZiBcuM4smz3\/3\/6PkrPjCgfppBMFWB53DgRx2whs4raMWJ7dv938H8\/KVGdjkR1qrNx+13ehftTU9w889V+vVOHqySq05GoTnU2br\/Lu3B\/aoqbZ77ar3fqcJVEdToS1anOxu13eRfuT01x88xX+\/VOHa6SqE5HojrV2bj9Lu\/C\/akpbp75ar\/eeT2cids\/O6cp6Xzad6zeR1PS+bSfovYfz+vhTNz+2TlNSefTvmP1PpqSzqf9FLX\/eF4PZ+L2z85pSjqf9h2r99GUdD7tp6j9x\/N6OBO3f3ZOU9L5tO9YvY+mpPNpP0XtP57XwwpzJ3E5Wd0n6fyn+93c4eZdTlyfuZOo\/HheDyvMncTlZHWfpPOf7ndzh5t3OXF95k6i8uN5PawwdxKXk9V9ks5\/ut\/NHW7e5cT1mTuJyo\/n9bDC3ElcTlb3STr\/6X43d7h5lxPXZ+4kKj+e18MKcydJc0pUZyRRnSr56ZwSl5O07+A+StLcSVR+PK+HFeZOkuaUqM5IojpV8tM5JS4nad\/BfZSkuZOo\/HheDyvMnSTNKVGdkUR1quSnc0pcTtK+g\/soSXMnUfnxvB5WmDtJmlOiOiOJ6lTJT+eUuJykfQf3UZLmTqLy43k9rDB3EpcT1\/90TtjvSlyewn2UqM5IkuZOovLjeT2sMHcSlxPX\/3RO2O9KXJ7CfZSozkiS5k6i8uN5PawwdxKXE9f\/dE7Y70pcnsJ9lKjOSJLmTqLy43k9rDB3EpcT1\/90TtjvSlyewn2UqM5IkuZOovLjeT2cSbqffZqidqw0Zf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t1c9JtzKr92pu8x\/j8YukJ6PswavzispGcy57xau5V+cnLt9sNpvNZrPZbDabzWaz2Ww2m81M\/ve\/\/wclQxXDBQHQjQAAAABJRU5ErkJggg==","fileSize":"8484","returnCode":"0"}');
A call to json_decode($json['JSONDataResult'], TRUE) decodes the big string into an array like this:
array(
'file' => 'iVBORw0KGgoAAAANSUhEUgAAALUAAAEZCAYAAADR+mSIAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABhuSURBVHhe7ZiBcuM4smz3/3/6PkrPjCgfppBMFWB53DgRx2whs4raMWJ7dv938H8/KVGdjkR1qrNx+13ehftTU9w889V+vVOHqySq05GoTnU2br/Lu3B/aoqbZ77ar3fqcJVEdToS1anOxu13eRfuT01x88xX+/VOHa6SqE5HojrV2bj9Lu/C/akpbp75ar/eeT2cids/O6cp6Xzad6zeR1PS+bSfovYfz+vhTNz+2TlNSefTvmP1PpqSzqf9FLX/eF4PZ+L2z85pSjqf9h2r99GUdD7tp6j9x/N6OBO3f3ZOU9L5tO9YvY+mpPNpP0XtP57XwwpzJ3E5Wd0n6fyn+93c4eZdTlyfuZOo/HheDyvMncTlZHWfpPOf7ndzh5t3OXF95k6i8uN5PawwdxKXk9V9ks5/ut/NHW7e5cT1mTuJyo/n9bDC3ElcTlb3STr/6X43d7h5lxPXZ+4kKj+e18MKcydJc0pUZyRRnSr56ZwSl5O07+A+StLcSVR+PK+HFeZOkuaUqM5IojpV8tM5JS4nad/BfZSkuZOo/HheDyvMnSTNKVGdkUR1quSnc0pcTtK+g/soSXMnUfnxvB5WmDtJmlOiOiOJ6lTJT+eUuJykfQf3UZLmTqLy43k9rDB3EpcT1/90TtjvSlyewn2UqM5IkuZOovLjeT2sMHcSlxPX/3RO2O9KXJ7CfZSozkiS5k6i8uN5PawwdxKXE9f/dE7Y70pcnsJ9lKjOSJLmTqLy43k9rDB3EpcT1/90TtjvSlyewn2UqM5IkuZOovLjeT2cSb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0,
);
The value of file is encoded using base64. The complete code should look like this:
// Decode the JSON
$fileInfo = json_decode($json, TRUE);
// Decode the file content
$content = base64_decode($fileInfo['file']);
// Visually inspect its the decoded file content
print_r($content); // Congratulations, it's a PNG!
// Put the content in a file
file_put_contents('...the file path here...', $content);
// Use getimagesize() to learn about the image type
// an rename the file using the correct termination.
Btw, the value of fileSize is the length of the file field, i.e. the content encoded using base64, not the length of the actual PNG file on disk (as I would expect).
You tried to
$json = json_decode($data[0], true); //array
???
(mind the access on the first field on $data)
I'm trying to write the array $jsonDataInArray to an external csv file. Right now, my file only has the column headers without the data underneath. Could someone help me step through this PHP array, $jsonDataInArray, and write it to an external .csv file?
//set url for pipedrive data being pulled
$api_token="soemToken";
$url = "https://someURL.com;
$ch = curl_init(); //initialize connection with a URL
//check if cURL is enabled or not
if(is_callable('curl_init'))
{
echo "curl_init Enabled";
}
else
{
echo "curl_init Not enabled";
}
echo '<br/><br/><br/><br/><br/><br/>';
curl_setopt($ch, CURLOPT_URL, $url); //fetching URL
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //return queried data as string
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);//verify certificate
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);//check the existence of a common name & verify that it matches the hostname provided
curl_setopt ($ch, CURLOPT_CAINFO, dirname(__FILE__)."/permissingFile.pem");//name of file holding certificates to verify peer with
$json_response = curl_exec($ch);//perform cURL session. Returns ALL of JSON data if sucessful, false if not.
$info = curl_getinfo($ch);//gets array of info about cURL transfer.
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);//gets HTTP message about cURL transfer
if ( $status != 200 )
{
die("Error: call to URL $url failed with status $status, response $json_response, curl_error " . curl_error($ch) . ", curl_errno " . curl_errno($ch));
//die();
}
curl_close($ch);//close connection with URL
// create an array from the data that is sent back from the API
$response = json_decode($json_response, 1);
// Gets the count of records returned from the api. Used in the for loop to go through response 1 array element at a time.
$count = Count($response['data']);
for ($x=0; $x<$count; $x++)
{
$currentRecord = $response['data'][$x];
$jsonDataInArray = array
(
"id" => $response['data'][$x]['id'],
"user_id" => $response['data'][$x]['user_id']['id'],
"person_id" => $response['data'][$x]['person_id']['value'],
"org_id" => $response['data'][$x]['org_id']['value'],
"stage_id" => $response['data'][$x]['stage_id'],
"title" => $response['data'][$x]['title'],
"value" => $response['data'][$x]['value'],
"currency" => $response['data'][$x]['currency'],
"add_time" => $response['data'][$x]['add_time'],
"update_time" => $response['data'][$x]['update_time'],
"stage_change_time" => $response['data'][$x]['stage_change_time'],
"active" => $response['data'][$x]['active'],
"deleted" => $response['data'][$x]['deleted'],
"status" => $response['data'][$x]['status'],
);
ksort($currentRecord);
}
$test_array = $response['data'][0];//test_array = first row of data
if($startPos == 0){
$fp = fopen('cacheDeals3.csv', 'w');
fputcsv($fp, array_keys($response['data'][0]));
}else{
$fp = fopen('cacheDeals3.csv', 'a');
}
foreach ($jsonDataInArray as $fields)
{
fputcsv($fp, $fields);
}
$jsonDataInArray is being overwritten on every iteration of the for loop, therefore fputcsv is being passed a string as the $field parameter rather than an array.
You need to append a new array to $jsonDataInArray each time, change
$jsonDataInArray = array
to
$jsonDataInArray[] = array
This question already has answers here:
Reference: What is variable scope, which variables are accessible from where and what are "undefined variable" errors?
(3 answers)
Closed 7 years ago.
I have this snippet of a function inside a larger php class.
I also get some simple data from my database which I have trouble getting into the array when fetching the variables.
$json = array();
$params = array(
'receiver_name' => $var,
'receiver_address1' => 'this works'
);
$ch = curl_init();
$query = http_build_query($params);
curl_setopt($ch, CURLOPT_URL, self::API_ENDPOINT . '/' . 'shipments/imported_shipment');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec ($ch);
$http_code = curl_getinfo( $ch, CURLINFO_HTTP_CODE);
curl_close ($ch);
$output = json_decode($output, true);
I've tried to assign the variable before the array starts, like this:
$var = $row['field_1'];
But it doesn't work when I try to insert this code. So I then tried:
$var2 = "'$var'"; // but quickly went back.
Since I thought it might have something to do with the quotes. I've tried several other ways of getting the variable to pass properly into the array. But when I don't know exactly what to read up on, I get stuck like this.
$params = array(
'receiver_name' => ".$var.", //this prints ..
'receiver_name' => "'.$var.'", //this prints '..'
Perhaps someone on here can tell me what terminology I should use for searching for more information related to this subject, as I seemingly have alot to read up on?
Update
I think everything should be cut out and simplified nicely now?
<?php
while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
{
$p_name = $row['input_name'];
}
echo $p_name; // echo's correctly
class labels {
public function myFunction() {
$json = array();
$params = array(
'token' => $this->_token,
'name' => $p_name,
'hardcoded' => 'works fine'
);
}
}
echo $p_name; // echo's correctly
?>
You're trying to use a variable that is declared outside of the local scope of the class. You need to pass that variable as parameter for the class method.
class labels {
public function myFunction($p_name) {
$json = array();
$params = array(
'token' => $this->_token,
'name' => $p_name,
'hardcoded' => 'works fine'
);
}
}
And when you call your method
$labels = new labels();
$labels->myFunction($p_name);
Then it should work.
I'm currently trying to send POST data to a URL via curl. The URL that the data is sent to is the URL on which the form is located on. In other words the form "action" is itself.
The problem is, on the form page, a random hidden input value is set on each refresh, and I need to get those values, and use them alongside the other data I want to post. Here is my current code:
<?php
function httpPost($url,$params) {
$postData = '';
$proxy = "127.0.0.1";
$port = "9150";
// Create name value pairs seperated by &
foreach($params as $k => $v) {
$postData .= $k . '='.urlencode($v).'&';
}
rtrim($postData, '&');
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, count($postData));
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt ($ch, CURLOPT_PROXYTYPE, 7 );
curl_setopt ($ch, CURLOPT_PROXY, $proxy.':'.$port );
$output=curl_exec($ch);
curl_close($ch);
return $output;
}
$content = file_get_contents('https://secured.example.com/directory/create');
$params = array(
"name" => "Name",
"pass" => "password",
"email" => "email#email.com"
);
echo httpPost("https://secured.example.com/directory/create",$params);
?>
For instance, on https://secured.example.com/directory/create there is a hidden input field that looks like this:
<input type="hidden" name="anon_token" value="ZHvR0DtwB-15Os0qwdVE3IN_ygSHHhllDAkOUwVPtZE" />
However, the value is randomly set each time (refresh).
After fetching the content, you need to grab the value of anon_token.
This basically uses the content of the HTML page as new DOMDocument.
Then all input tags are fetched, to find the one input tag containing "anon_token".
From this tag you want the value (which is the token).
The token needs to be inserted into the POST data array.
Side-note: a simple preg_match might work, too. But, anyway let's play it safe by using Dom-functions.
$content = file_get_contents('https://secured.example.com/directory/create');
$doc = new DOMDocument();
$doc->loadHTML($content);
$tags = $doc->getElementsByTagName('input');
foreach ($tags as $tag) {
if($tag->getAttribute('name') === 'anon_token') {
$token = $tag->getAttribute('value');
}
}
$params = array(
"name" => "Name",
"pass" => "password",
"email" => "email#email.com",
"anon_token" => $token
);
With preg_match()..
preg_match('/name="anon_token"\svalue="(.*)"/', $content, $matches)
$token = $matches[0];
Hope this works:
$content = file_get_contents("https://secured.example.com/directory/create");
$pattern = "/hidden.*name=[\s|'|\"]anon_token.*value=.*[\"']/";
preg_match( $pattern , $content , $matches);
$pattern_value = "/hidden.*name=[\s|'|\"]anon_token.*value=/";
foreach($matches as $match){
echo preg_replace(array($pattern_value, "/'/" , '/"/') , array( "", "" , "") , $match);
}
I'm having an extrange issue when receiving parameters from a POST cURL request. No matter how I encode it (json, url, rawurl, utf8, base64...) before POSTing it, I am not able to perform any decoding operation through the array elements, via loop. I'm giving you the details.
From the consuming controller, in some other php (Yii) app, I build my request like this:
private function callTheApi($options)
{
$url = "http://api.call.com/url/api";
$params = array( 'api_key' => $this->api_key,
'domain' => $this->domain,
'date' => $options['date'],
'keys' => $options['keys'] // This is an array
);
// Following some good advice from Daniel Vandersluis here:
// http://stackoverflow.com/questions/3772096/posting-multidimensional-array-with-php-and-curl
if (is_array($params['keys'])
{
foreach ($params['keys'] as $id => $name)
{
$params['keys[' . $id . ']'] = $name;
}
unset($params['keys']);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: multipart/form-data; charset=utf-8'));
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_USERAGENT,
"Mozilla/5.0 (Windows; U; Windows NT 5.0; en; rv:1.9.0.4) "
. "Gecko/2009011913 Firefox/3.0.6");
$output = curl_exec($ch);
$error = curl_errno($ch);
$error_text = curl_error($ch);
curl_close($ch);
if (!$output || $error != 0)
die("<br><hr>Problems...<br>"
. "Line:" . __LINE__ . " dataExtractor.php<br>"
. "Error: " . $error . " - " . $error_text . "<hr>"
. $url . "<hr>");
sleep(1);
return json_decode($output, true);
}
And in the api itself, this is the function:
public function api()
{
$params = $_POST;
foreach($params as $k=>$v){
if($k=='domain') $domain = $v;
if($k=='date') $date = $v;
if($k=='api_key') $api_key = $v;
if($k=='keys') $keys = $v;
}
echo json_encode($keys);
// All my logic would be here, after parsing the array correctly.
}
Ok, now for the problems:
If i leave everything like stated before, it works. I have my $keys array in the api, and I can use it however I want. The "echo json_encode($keys)" sentence returns the array ALMOST as it should be. But the problem is some values of the array are corrupted in the cURL operation. Values such as spanish characters á, é ,í, ó, ú OR ü are simply not present in the array_values.
If some key in the $keys array was spanish word "alimentación" in the original array, once it's been cURLed to the api, it becomes "alimentacin". There, the ó is not there anymore.
So, my chances are encoding each value in the array to a safely transferred value, so that I can decode it later. But what do you know, I can't.
I've tried urlencoding, rawurlencoding, json_encoding, base64_encoding... each value of the array. And if I return the received array from the api, it contains the encoded values all right. BUT.
If I loop the array in the api for decoding, and then try to return it, no matter what decoding function I'm applying to its values, the output is ALWAYS "NULL".
I have no clue what I'm doing wrong here. Not even close.
So any help would be much appreciated. Thanks in advance, community.
When you create cUrl params array you should know that keys cannot be utf8.
And when you add some parameters in foreach loop
$params['keys[' . $id . ']'] = $name;
$id can be utf8 character.
To avoid that I recommend you to use json_encode
$params = array(
'api_key' => $this->api_key,
'domain' => $this->domain,
'date' => $options['date'],
'keys' => json_encode($options['keys']) // This is an array
);
In your api in this case you should change nothing.