I need to print json response in php/html table, I am stuck for 4 days..
i have the json response as follows, it displays on the link http://localhost:8080/fb/?code=AQCtq-HglnDn5OZGCZAgnqiDHgL6fRHIC0054JJs6HgMmqw8h_qNDSqToe4ZxAM6kkGLDIzUaoruR0rfSlSenwRnWNv6Q6TH0Gbf6jbQ73m1uVEYnt_jrPiyawtKvj6bASITtMFC41Lly5SO25NOBRXP00RWN3uQoB3SxOe3ok3eypFZ26IRW1amNhDj3QdknvjpqsrpyhEUwK3NnHkRZmQqCKdvXywcZ-ENRxYAwN1rg4Gt0-fsdpnnKaQNx63MkXm6qEiSyIMPnZVHE7QPAJzIgdmUtK-aJD5lePpoIVJKT9P-Yy0R3ZIB2rHR5OTorx1WUOs5gHI7ANDEQnJN4mB4&state=32c7de5b745a4def2865de6684770d2d#=
array(3) {
["data"]=>
array(25) {
[0]=>
array(2) {
["id"]=>
string(15) "961716293930505"
["name"]=>
string(10) "Nena Gomez"
}
[1]=>
array(2) {
["id"]=>
string(15) "738589686317947"
["name"]=>
string(13) "Betuxx Chacon"
}
[2]=>
array(2) {
["id"]=>
string(17) "10154358290553845"
["name"]=>
string(24) "Gabriel Heredia Briseño"
}
[3]=>
array(2) {
["id"]=>
string(16) "1568587126490267"
["name"]=>
string(18) "Armando Von Thesse"
}
[4]=>
array(2) {
["id"]=>
string(17) "10211420006316586"
["name"]=>
string(11) "Any Obregon"
}
[5]=>
array(2) {
["id"]=>
string(16) "1464100830268739"
["name"]=>
string(35) "AarOnn LeOnne Raamiireez Raamiireez"
}
[6]=>
array(2) {
["id"]=>
string(16) "1210996895614354"
["name"]=>
string(23) "María José Hernández"
}
[7]=>
array(2) {
["id"]=>
string(17) "10205997740821868"
["name"]=>
string(14) "Mario Martinez"
}
[8]=>
array(2) {
["id"]=>
string(16) "1898457230384035"
["name"]=>
string(23) "Veronica Ramirez Cuevas"
}
[9]=>
array(2) {
["id"]=>
string(16) "1333307456741256"
["name"]=>
string(17) "Nicacio González"
}
[10]=>
array(2) {
["id"]=>
string(17) "10210081324343375"
["name"]=>
string(20) "Ariela Ampai Herrera"
}
[11]=>
array(2) {
["id"]=>
string(16) "1383385655027101"
["name"]=>
string(10) "Leyda Luna"
}
[12]=>
array(2) {
["id"]=>
string(17) "10154085294360936"
["name"]=>
string(17) "Ivan Azael Rivera"
}
[13]=>
array(2) {
["id"]=>
string(16) "1839478686312278"
["name"]=>
string(16) "Isamar Rodriguez"
}
[14]=>
array(2) {
["id"]=>
string(15) "954280078035568"
["name"]=>
string(32) "Seylin Mariana Brenes Peñaranda"
}
[15]=>
array(2) {
["id"]=>
string(16) "1220976504656199"
["name"]=>
string(17) "Yamili Ch Smendez"
}
[16]=>
array(2) {
["id"]=>
string(16) "1231937083552234"
["name"]=>
string(13) "Kennya Huerta"
}
[17]=>
array(2) {
["id"]=>
string(16) "1055827734543856"
["name"]=>
string(22) "Lizarazu Mario Esteban"
}
[18]=>
array(2) {
["id"]=>
string(15) "692883830880037"
["name"]=>
string(14) "Luian Suyos CA"
}
[19]=>
array(2) {
["id"]=>
string(16) "1223005904451888"
["name"]=>
string(12) "Rojas Andres"
}
[20]=>
array(2) {
["id"]=>
string(16) "1330174903721200"
["name"]=>
string(13) "Andrey Muñoz"
}
[21]=>
array(2) {
["id"]=>
string(17) "10210287624562868"
["name"]=>
string(27) "Carlos Manuel Veloz Sanchez"
}
[22]=>
array(2) {
["id"]=>
string(16) "1454728524567426"
["name"]=>
string(14) "Brandon Marín"
}
[23]=>
array(2) {
["id"]=>
string(16) "1809382102646429"
["name"]=>
string(27) "Dulce Maria Garcia Alvarado"
}
[24]=>
array(2) {
["id"]=>
string(15) "244610952637604"
["name"]=>
string(12) "Nafancy Soto"
}
}
["paging"]=>
array(2) {
["cursors"]=>
array(2) {
["before"]=>
string(20) "OTYxNzE2MjkzOTMwNTA1"
["after"]=>
string(20) "MjQ0NjEwOTUyNjM3NjA0"
}
["next"]=>
string(296) "https://graph.facebook.com/v2.8/778837615590033/likes?access_token=EAAW6655F9B8BADxO2m3VFKuNs7mEifqLGhDWEBxUtvL9jF8x8ZATLWUl0ZBR6jephQjNpWuuZCbgosbZCZAaNJLxeJ9seTxBQPneYGWMvf2I89ZAt2jOdV3rJu7iemXniCG6LiWDdUyjBl43ocEaRXPTN5qxzlPgcZD&pretty=1&summary=total_count&limit=25&after=MjQ0NjEwOTUyNjM3NjA0"
}
["summary"]=>
array(1) {
["total_count"]=>
int(28215)
}
}
likes count 28215
and my code is
<?php
session_start();
require_once __DIR__ .'/Facebook/autoload.php';
$fb = new \Facebook\Facebook([
'app_id' => '1612896019018783',
'app_secret' =>'483a369576ee496cce5780b0d5e23202' ,
'default_graph_version' => 'v2.8',
]);
$permissions = ['user_photos'];
$helper = $fb->getRedirectLoginHelper();
$accessToken=$helper->getAccessToken();
if(isset($accessToken)){
$url = "https://graph.facebook.com/v2.8/778837615590033/likes?&summary=total_count&access_token={$accessToken}";
//$url = "https://graph.facebook.com/v2.8/1205547979521647?fields=posts{likes,comments}&access_token={$accessToken}";
//$url = "https://graph.facebook.com/v2.8/1205547979521647?me?fields=id,name&access_token={$accessToken}";
$header=array("Content-type: application/json");
$ch=curl_init();
curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch,CURLOPT_COOKIEJAR,'cookie.txt');
curl_setopt($ch,CURLOPT_COOKIEFILE,'cookie.txt');
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_USERAGENT,"Mozilla/5.0 (Windows;U;
Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
$st=curl_exec($ch);
$result=json_decode($st,TRUE);
echo "<pre>";
var_dump($result);
echo "</pre>";
$likes = $result['summary']['total_count'];
echo "likes count ". $likes;
//echo "<center>";
//echo "<img width='700' height='450' src= ><br><br>";
//echo "<img width='90' height='90' src=http://i.imgur.com/wVAJS8T.png";
//echo "</center>";
}
else
{
$loginUrl = $helper->getLoginUrl('http://localhost:8080/fb/',$permissions);
echo 'Login with FB';
}
?>
I need to display the results in results.php in table format
$data = $result['data'];
echo '<table>';
echo '<tr><td>id</td><td>name</td></tr>';
foreach ($data as $item) {
echo '<tr>';
echo '<td>' . $item['id'] . '</td>';
echo '<td>' . $item['name'] . '</td>';
echo '</tr>';
addMysql($item['id'], $item['name']);
}
echo '</table>';
function addMysql($id, $name) {
$sql = "INSERT INTO table_name (`id`, `name`) VALUE ($id, $name);";
// instance mysql driver
mysql_query($sql);
}
Your $result is in array format.So just use the table tag as below.
$result=json_decode($st,TRUE);
echo "<table>";
foreach ($result as $res) {
echo "<tr>";
echo "<td>".$res['data']['id']."</td">;
echo "<td>".$res['data']['name']."</td>";
echo "</tr">;
}
echo "</table>"
Related
I have an array returned from Google Maps, that looks like this:
array(4) {
["destination_addresses"]=> array(4) {
[0]=> string(19) "Walsall WS2 9PS, UK"
[1]=> string(19) "Walsall WS2 9PS, UK"
[2]=> string(19) "Walsall WS2 9PS, UK"
[3]=> string(26) "Wolverhampton WV10 0QP, UK"
}
["origin_addresses"]=> array(1) {
[0]=> string(18) "Stone ST15 0FL, UK"
}
["rows"]=> array(1) {
[0]=> array(1) {
["elements"]=> array(4) {
[0]=> array(3) {
["distance"]=> array(2) {
["text"]=> string(7) "41.9 km"
["value"]=> int(41947)
}
["duration"]=> array(2) {
["text"]=> string(7) "36 mins"
["value"]=> int(2134)
}
["status"]=> string(2) "OK"
}
[1]=> array(3) {
["distance"]=> array(2) {
["text"]=> string(7) "41.9 km"
["value"]=> int(41947)
}
["duration"]=> array(2) {
["text"]=> string(7) "36 mins"
["value"]=> int(2134)
}
["status"]=> string(2) "OK"
}
[2]=> array(3) {
["distance"]=> array(2) {
["text"]=> string(7) "41.9 km"
["value"]=> int(41947)
}
["duration"]=> array(2) {
["text"]=> string(7) "36 mins"
["value"]=> int(2134)
}
["status"]=> string(2) "OK"
}
[3]=> array(3) {
["distance"]=> array(2) {
["text"]=> string(7) "40.9 km"
["value"]=> int(40924)
}
["duration"]=> array(2) {
["text"]=> string(7) "41 mins"
["value"]=> int(2458)
}
["status"]=> string(2) "OK"
}
}
}
}
["status"]=> string(2) "OK"
}
I want to be able to run through the array, and print the destination address and the distance and time values.
This prints the destination addresses ok:
$length=count($properties);
for($a=0;$a<$length;$a++)
{
echo '</br>Index is ' . $a . ' | id is ' . $index[$a] . ' | destination is ' . $properties["destination_addresses"][$a] . ' | time is ';
}
But I can't figure out how to print the rest. I've been banging my head against the wall all night!
Thank you in anticipation.
To loop over all these journeys and print the distance and time for each potential journey, create a foreach loop and then use the $idx to address the subordinate parts of the muleiple arrays
foreach( $destination['destination_addresses'] as $idx => $to ) {
if ( $destination['rows'][0]['elements'][$idx]['status'] == 'OK' ) {
echo 'Going from ' . $destination['origin_addresses'][0];
echo ' To ' . $to;
echo ' Distance ' . $destination['rows'][0]['elements'][$idx]['distance']['text'];
echo ' Duration ' . $destination['rows'][0]['elements'][$idx]['duration']['text'];
} else {
//whatever you do if the status is not OK
}
}
array(2) { [0]=> array(2) { ["name"]=> string(16) "Daerah Pertanian" ["sub"]=> array(6) { [0]=> array(2) { ["name"]=> string(5) "Sawah" ["value"]=> string(3) "145" } [1]=> array(2) { ["name"]=> string(18) "Sawah Pasang Surut" ["value"]=> string(3) "455" } [2]=> array(2) { ["name"]=> string(6) "Ladang" ["value"]=> string(3) "678" } [3]=> array(2) { ["name"]=> string(10) "Perkebunan" ["value"]=> string(3) "688" } [4]=> array(2) { ["name"]=> string(19) "Perkebunan Campuran" ["value"]=> string(3) "966" } [5]=> array(2) { ["name"]=> string(16) "Tanaman Campuran" ["value"]=> string(3) "565" } } } [1]=> array(2) { ["name"]=> string(22) "Daerah Bukan Pertanian" ["sub"]=> array(2) { [0]=> array(2) { ["name"]=> string(18) "Hutan Lahan Kering" ["sub"]=> array(2) { [0]=> array(2) { ["name"]=> string(25) "Hutan Lahan Kering Primer" ["value"]=> string(3) "566" } [1]=> array(2) { ["name"]=> string(27) "Hutan Lahan Kering Sekunder" ["value"]=> string(3) "255" } } } [1]=> array(2) { ["name"]=> string(17) "Hutan Lahan Basah" ["sub"]=> array(2) { [0]=> array(1) { ["name"]=> string(24) "Hutan Lahan Basah Primer" } [1]=> array(1) { ["name"]=> string(26) "Hutan Lahan Basah Sekunder" } } } } } }
I have an array like I mention above, so I want to print out every "name" key including the index (number) of it's array parent,
for example when I print out "Tanaman Campuran" so all index parent is (0)(5) and when I print "Hutan Lahan Basah Sekunder" the index parent is (1)(1)(1)
how can I achieve it?
here is some recursive function that I've tried
$GLOBALS['all'] = '';
function printout($arr){
foreach ($arr as $ia=>$a){
if(is_array($a)){
foreach ($a as $ib=>$b){
if(is_array($b)){
printout($b);
}
else{
if ($ib == 'name') {
$GLOBALS['all'] .= $ia;
echo '<tr>';
echo '<td>' . $b . ' (' . $ia . ')</td>';
echo '</tr>';
$GLOBALS['all'] = '';
}
}
}
}
}
}
*sorry for my bad explanation, I hope you guys can understand it
You could use the following function:
function search(array $array, $name)
{
foreach ($array as $key => $entry) {
if ($entry['name'] === $name) {
return [$key];
}
if (isset($entry['sub']) && $found_keys = search($entry['sub'], $name)) {
return array_merge([$key], $found_keys);
}
}
return null;
}
It returns:
if the value was directly found, an array of one containing the associated index,
if it wasn't but was found in any descendant item, an array merging its index with the indices of said descendant,
null if it wasn't found in that part of the tree.
Note: if a given name is present several times, it will only find the first occurrence.
Demo: https://3v4l.org/1hGr1
I am using the PHP specific SOAPClient in order to call for a soap API and get responses.
The problem I have is that I do not manage to get in order the results, neither to extract them.
The code I am using is:
<?php
$wsdl = 'http://portalquery.just.ro/Query.asmx?wsdl';
$client = new SoapClient($wsdl);
$xml_array['numarDosar'] = '10080/3/2013';
$response = $client->CautareDosare2($xml_array);
var_dump($response);
?>
The results I get are:
object(stdClass)#2 (1) { ["CautareDosare2Result"]=> object(stdClass)#3 (1) { ["Dosar"]=> array(2) { [0]=> object(stdClass)#4 (13) { ["parti"]=> object(stdClass)#5 (1) { ["DosarParte"]=> array(3) { [0]=> object(stdClass)#6 (2) { ["nume"]=> string(22) "Mocanu Andrei Cristian" ["calitateParte"]=> string(17) "Recurent Inculpat" } [1]=> object(stdClass)#7 (2) { ["nume"]=> string(21) "Mocanu Răzvan George" ["calitateParte"]=> string(17) "Recurent Inculpat" } [2]=> object(stdClass)#8 (2) { ["nume"]=> string(11) "Mica Marian" ["calitateParte"]=> string(17) "Recurent Inculpat" } } } ["sedinte"]=> object(stdClass)#9 (1) { ["DosarSedinta"]=> object(stdClass)#10 (9) { ["complet"]=> string(26) "S2 Complet urgentă recurs" ["data"]=> string(19) "2013-03-14T00:00:00" ["ora"]=> string(5) "12:00" ["solutie"]=> string(14) "Respins recurs" ["solutieSumar"]=> string(408) "Înc. 82/R/În majoritate :Respinge ca nefondate recursurile declararate de recurenţii inculpaţi Mocanu Andrei Cristian, Mocanu Răzvan George şi Mica Marian. Obligă pe fiecare recurent la câte 300 lei cheltuieli judiciare către stat. Pronunţată în şedinţă publică, azi, 14.03.2013. Opinie separată în sensul admiterii recursurilor şi luării măsurii obligării de a nu părăsi localitatea." ["dataPronuntare"]=> string(19) "2013-03-14T00:00:00" ["documentSedinta"]=> string(33) "incheieremasuripreventivefazadeUP" ["numarDocument"]=> string(7) "82/2013" ["dataDocument"]=> string(19) "2013-03-14T00:00:00" } } ["numar"]=> string(12) "10080/3/2013" ["numarVechi"]=> string(8) "831/2013" ["data"]=> string(19) "2013-03-14T00:00:00" ["institutie"]=> string(21) "CurteadeApelBUCURESTI" ["departament"]=> string(22) "Secţia a II-a penală" ["categorieCaz"]=> string(5) "Penal" ["stadiuProcesual"]=> string(6) "Recurs" ["obiect"]=> string(113) "prelungirea duratei arestării preventive dispuse în cursul urmăririi penale (art. 156 şi următoarele C.p.p.)" ["dataModificare"]=> string(23) "2017-01-18T06:48:34.467" ["categorieCazNume"]=> string(5) "Penal" ["stadiuProcesualNume"]=> string(6) "Recurs" } [1]=> object(stdClass)#11 (14) { ["parti"]=> object(stdClass)#12 (1) { ["DosarParte"]=> array(3) { [0]=> object(stdClass)#13 (2) { ["nume"]=> string(22) "MOCANU ANDREI CRISTIAN" ["calitateParte"]=> string(8) "Inculpat" } [1]=> object(stdClass)#14 (2) { ["nume"]=> string(20) "MOCANU RAZVAN GEORGE" ["calitateParte"]=> string(8) "Inculpat" } [2]=> object(stdClass)#15 (2) { ["nume"]=> string(11) "MICA MARIAN" ["calitateParte"]=> string(8) "Inculpat" } } } ["sedinte"]=> object(stdClass)#16 (1) { ["DosarSedinta"]=> object(stdClass)#17 (9) { ["complet"]=> string(5) "CC1 -" ["data"]=> string(19) "2013-03-12T00:00:00" ["ora"]=> string(5) "23:59" ["solutie"]=> string(12) "Soluţionare" ["solutieSumar"]=> string(311) "În baza prevederilor art. 155 şi urm. C.p.p. dispune prelungirea măsurii arestării preventive a inculpaţilor Mocanu Andrei Cristian, Mocanu Răzvan George şi Mica Marius pe o perioadă de 20 de zile, de la 15.03.2013 - 03.04.2013, inclusiv. Cu recurs. Pronunţată în şedinţă publică azi, 12.03.2013." ["dataPronuntare"]=> string(19) "2013-03-12T00:00:00" ["documentSedinta"]=> string(27) "incheierefinaladezinvestire" ["numarDocument"]=> string(0) "" ["dataDocument"]=> string(19) "2013-03-12T00:00:00" } } ["caiAtac"]=> object(stdClass)#18 (1) { ["DosarCaleAtac"]=> object(stdClass)#19 (3) { ["dataDeclarare"]=> string(19) "2013-03-13T00:00:00" ["parteDeclaratoare"]=> string(37) " MICA MARIAN, MOCANU RAZVAN GEORGE, " ["tipCaleAtac"]=> string(6) "Recurs" } } ["numar"]=> string(12) "10080/3/2013" ["numarVechi"]=> string(0) "" ["data"]=> string(19) "2013-03-11T00:00:00" ["institutie"]=> string(19) "TribunalulBUCURESTI" ["departament"]=> string(22) "Secţia a-II-a Penală" ["categorieCaz"]=> string(5) "Penal" ["stadiuProcesual"]=> string(4) "Fond" ["obiect"]=> string(113) "prelungirea duratei arestării preventive dispuse în cursul urmăririi penale (art. 156 şi următoarele C.p.p.)" ["dataModificare"]=> string(23) "2017-01-18T08:33:50.877" ["categorieCazNume"]=> string(5) "Penal" ["stadiuProcesualNume"]=> string(4) "Fond" } } } }
I tried to explode on the results, also used $response[1]->array and such, nothing works.
<?php
ini_set("display_errors", 1);
$wsdl = 'http://portalquery.just.ro/Query.asmx?wsdl';
$client = new SoapClient($wsdl);
$xml_array['numarDosar'] = '10080/3/2013';
$response = $client->CautareDosare2($xml_array);
$resultArray= json_decode(json_encode($response),true);
$arrayOnfirstKey=$resultArray[key($resultArray)];
$arrayOnSecondKey= $arrayOnfirstKey[key($arrayOnfirstKey)];
echo "<table>";
echo "<tr>";
echo "<td>nume</td>";
echo "<td>CalitateParte</td>";
echo "</tr>";
foreach($arrayOnSecondKey as $value)
{
foreach($value["parti"]["DosarParte"] as $data)
{
echo "<tr>";
echo "<td>" .$data["nume"]."</td>";
echo "<td>" .$data["calitateParte"]."</td>";
echo "</tr>";
}
}
echo "</table>";
i have two csv files: one contracts data and the other containing awarded contracts. I need to combine these two files using common field(contractname) and compute total amount of current awarded contracts.
Link to csv files:
https://github.com/younginnovations/problem-statements/tree/master/clean-up-contracts-data
I do get desired output bt undefined offset error comes up.
the code:unset(awards_info[$y][0]); does unsets the data but 'Undefined offset: 0' error occurs..
similarly the code $list_data[10]!=NULL also shows the same error
but both are producing desired output.
var_dump($awards_info):: produces following:
array(5) { [0]=> array(6) { [0]=> string(12) "contractName" [1]=> string(12) "contractDate" [2]=> string(14) "completionDate" [3]=> string(7) "awardee" [4]=> string(15) "awardeeLocation" [5]=> string(6) "Amount" } [1]=> array(6) { [0]=> string(15) "Contract-2070-3" [1]=> string(8) "5/9/2014" [2]=> string(9) "8/25/2014" [3]=> string(11) "SK Builders" [4]=> string(5) "Banke" [5]=> string(6) "200000" } [2]=> array(6) { [0]=> string(15) "Contract-2070-5" [1]=> string(9) "3/18/2014" [2]=> string(8) "4/8/2014" [3]=> string(24) "S engineering industries" [4]=> string(9) "Makwanpur" [5]=> string(6) "300000" } [3]=> array(6) { [0]=> string(15) "Contract-2070-9" [1]=> string(8) "3/6/2014" [2]=> string(8) "4/6/2014" [3]=> string(24) "Gourishankar nirman sewa" [4]=> string(8) "Lalitpur" [5]=> string(6) "400000" } [4]=> array(6) { [0]=> string(16) "Contract-2070-10" [1]=> string(8) "2/6/2014" [2]=> string(9) "6/16/2014" [3]=> string(11) "SK Builders" [4]=> string(5) "Banke" [5]=> string(6) "400000" } }
$file_contract=fopen('contracts.csv','r');
$file_awards=fopen('awards.csv','r');
while(($data=fgetcsv($file_contract))!=FALSE){
$contracts_info[]=$data;
}
while(($data=fgetcsv($file_awards))!=FALSE){
$awards_info[]=$data;
}
$con_count=count($contracts_info);
for($x=0;$x<$con_count;$x++){
if($x==0){
unset($awards_info[0][0]);
$data[$x]=array_merge($contracts_info[0],$awards_info[0]);
}
else{
$check=0;
$award_count=count($awards_info);
for($y=1;$y<$award_count;$y++){
if($awards_info[$y][0]==$contracts_info[$x][0]){
unset($awards_info[$y][0]);
$data[$x]=array_merge($contracts_info[$x],$awards_info[$y]);
$check=1;
}
}
if($check==0){
$data[$x]=$contracts_info[$x];
}
}
}
$final_data=fopen('final.csv','w');
foreach($data as $list_data){
fputcsv($final_data,$list_data);
}
fclose($final_data);
$c=0;
foreach ($data as $list_data){
if(($list_data[1]=='Current') && ($list_data[10]!=NULL))
{
$c+=$list_data[12];
}
}
echo $c;
You can just add the content file in the new file, without parsing files :
$fp = fopen('final.csv','w');
fwrite($fp, file_get_contents('contracts.csv'));
fwrite($fp, file_get_contents('awards.csv'));
fclose($fp);
echo file_get_contents('final.csv');
ok it's a wrong way. So i try to rewrite the loop :
for($x=0; $x < count($contracts_info); $x++) {
$data[$x] = $contracts_info[$x];
if($x == 0) {
if(isset($awards_info[$x])) {
$data[$x] = array_merge($data[$x], $awards_info[$x]);
unset($awards_info[$x]);
}
} else {
foreach($awards_info as $y => $award_info_datas) {
if($award_info_datas[0] == $contracts_info[$x][0]) {
$data[$x] = array_merge($data[$x], $award_info_datas);
unset($awards_info[$y]);
break;
}
}
}
}
I'm trying to use the library jmathai/twitter-async to send tweets, but I get an exception with no message :
//not logged in:
if($oauth_token == '')
{
try
{
$authorizationUrl = $twitterObj->getAuthorizeUrl();
/*
if (isset($authorizationUrl))
{
$twitterMessage = '<p>'._('twitter.signin.message').' : '.
'<a href="'. $authorizationUrl. '">'.
'<img class="signin" src="images/sign-in.png" /></a></p>';
}
else
{
$twitterMessage .= '<p>'._('twitter.error.message').' (error 1)</p>';
}
*/
}
catch(EpiTwitterException $e)
{
$twitterMessage .= 'epiError '.$e->getCode() . ' ' . $e->getMessage();
}
catch(EpiOAuthException $e)
{
$twitterMessage .= 'oAutherror: '$e->getCode() . ' ' . $e->getMessage();
}
}
This echoes "oAutherror: 0 "
Here's the result of var_dump($e->getTrace()); :
array(3) {
[0]=>
array(6) {
["file"]=>
string(70) "/.../lib/jmathai-twitter-async/EpiOAuth.php"
["line"]=>
int(404)
["function"]=>
string(5) "raise"
["class"]=>
string(17) "EpiOAuthException"
["type"]=>
string(2) "::"
["args"]=>
array(2) {
[0]=>
object(EpiCurlManager)#3 (2) {
["key:private"]=>
string(14) "Resource id #8"
["epiCurl:private"]=>
object(EpiCurl)#2 (9) {
["mc:private"]=>
resource(7) of type (curl)
["msgs:private"]=>
NULL
["running:private"]=>
NULL
["execStatus:private"]=>
NULL
["selectStatus:private"]=>
NULL
["sleepIncrement:private"]=>
float(1.1)
["requests:private"]=>
array(1) {
["Resource id #8"]=>
resource(8) of type (Unknown)
}
["responses:private"]=>
array(1) {
["Resource id #8"]=>
array(6) {
["data"]=>
bool(false)
["code"]=>
int(0)
["time"]=>
float(0)
["length"]=>
float(0)
["type"]=>
bool(false)
["url"]=>
string(43) "https://api.twitter.com/oauth/request_token"
}
}
["properties:private"]=>
array(5) {
["code"]=>
int(2097154)
["time"]=>
int(3145731)
["length"]=>
int(3145743)
["type"]=>
int(1048594)
["url"]=>
int(1048577)
}
}
}
[1]=>
bool(false)
}
}
[1]=>
array(6) {
["file"]=>
string(70) "/.../lib/jmathai-twitter-async/EpiOAuth.php"
["line"]=>
int(53)
["function"]=>
string(5) "__get"
["class"]=>
string(16) "EpiOAuthResponse"
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
string(11) "oauth_token"
}
}
[2]=>
array(6) {
["file"]=>
string(44) "/.../main.inc.php"
["line"]=>
int(29)
["function"]=>
string(15) "getAuthorizeUrl"
["class"]=>
string(8) "EpiOAuth"
["type"]=>
string(2) "->"
["args"]=>
array(0) {
}
}
The problem seems to have gona way when I removed the certificate from the folder (file named ca_bundle.crt).
See https://github.com/jmathai/twitter-async/issues/134