Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - MultiformeIngegno
136
Features / Re: More sidebar complications...
« on July 10th, 2013, 08:49 AM »
In iOS safari doesnt work
137
Features / Re: More sidebar complications...
« on July 2nd, 2013, 02:13 PM »
Maybe there could be 2 different sidebars for phones and tablets. The one for phones should have less items and should be smaller (and less intrusive). :)
138
Features / Re: More sidebar complications...
« on June 30th, 2013, 07:14 PM »
Right to left would switch to right tab :P
139
Features / Re: More sidebar complications...
« on June 30th, 2013, 05:21 PM »
Yep :)
I wonder though if that position can be "uncomfortable" on iOS 7, given that a swipe from left to right (on left side) would open the left tab (if multiple tabs are open).
140
Features / Re: More sidebar complications...
« on June 30th, 2013, 02:57 AM »
On iPhone 5 is unusable (triggers unexpectedly and text is enormous)..
141
Off-topic / Re: json_decode and arrays
« on June 14th, 2013, 01:23 PM »
This is the tree of my JSON (stored in $data_delicious):

Code: [Select]
{
   "@attributes":{
      "tag":"",
      "user":"myusername"
   },
   "post":[
      {
         "@attributes":{
            "description":"Fastweb: fibra o VDSL? Disinformazione alla porta",
            "extended":"",
            "hash":"d00d03acd6e01e9c2e899184eab35273",
            "href":"http:\/\/storify.com\/giovannibajo\/fastweb-fibra-o-vdsl",
            "private":"no",
            "shared":"yes",
            "tag":"",
            "time":"2013-06-14T10:30:08Z"
         }
      }
   ]
}

This is the function to grab stuff from it
Code: [Select]
$obj = $data_delicious['post']['@attributes'];

foreach (array_slice(json_decode($data_delicious, true), 0, 5) as $obj) {
    $delicious_title = str_replace('"', '\'', $obj['description']);
    $delicious_url = htmlentities($obj['href'], ENT_QUOTES, "UTF-8");
    $output = "<li><a rel=\"external nofollow\" title=\"$delicious_title\" href=\"$delicious_url\">$delicious_title</a></li>";
    echo $output;
}

Problem is I get these:
Illegal string offset 'post'
Illegal string offset '@attributes'
Undefined index: description
Undefined index: href
142
Off-topic / Re: json_decode and arrays
« on June 9th, 2013, 03:00 AM »
Fixed this too :)
143
Off-topic / Re: json_decode and arrays
« on June 8th, 2013, 06:22 PM »
Code: [Select]
    <?php
    
function get_photos($user_id=XXXX,$count=X,$width=XXX,$height=XXX,$token="XXXX"){
        
$url 'https://api.instagram.com/v1/users/'.$user_id.'/media/recent/?access_token='.$token.'&count='.$count;
        
$cache './BLAH/'.sha1($url).'.json';
        if(
file_exists($cache) && filemtime($cache) > time() - 1000){
            
$jsonData json_decode(file_get_contents($cache), true);
        } else {
            
$jsonData json_decode(file_get_contents($url), true);
            
file_put_contents($cache,json_encode($jsonData));
        }
        
$result '<div id="instagram">'.PHP_EOL;
$i 0;
        foreach (
$jsonData as $value) {
            
$title = (!empty($value->caption->text))?' '.$value->caption->text:'...';
        
BLAHBLAH
        
}
        
$result .= '</div>'.PHP_EOL;
        return 
$result;
    }
    echo 
get_photos();
    
?>

What's wrong with foreach ($jsonData as $value)? I'm grabbing an associative array with the "true" argument in json_decode.. isn't that foreach okay? Or does it grab objects instead?

Here's the json input: http://pastebin.com/EBGG10hx
144
The Pub / Re: Infinite Scroll
« on June 8th, 2013, 12:51 PM »
Yeah seems to work just fine! :D
145
The Pub / Re: Infinite Scroll
« on June 8th, 2013, 03:58 AM »
I have some issues when I try to like posts or post thoughts. The "loading" text loads forever and nothing happens. To solve I have to reload the page, post/like again and now works. Maybe this is related to the JS changes?
146
The Pub / Re: Infinite Scroll
« on June 7th, 2013, 12:25 PM »
:(
147
Off-topic / Re: json_decode and arrays
« on June 7th, 2013, 12:43 AM »
Solved.
It should have been $data_feedbin = $result;, not $data_feedbin = file_get_contents($result); :)
148
The Pub / Re: Infinite Scroll
« on June 6th, 2013, 11:57 PM »
I really really like it!! :D
I like also the fact that it takes a few more scrolls down when you arrive at the end of the page to actually have it activated.
149
The Pub / Re: Infinite Scroll
« on June 6th, 2013, 10:21 PM »
Would love to see it in action :D
150
Off-topic / Re: json_decode and arrays
« on June 6th, 2013, 10:02 PM »
Code: [Select]
<?php
$json_url 
'https://api.feedbin.me/v2/entries.json';
 
$username 'username';  // authentication
$password 'password';  // authentication
 
$ch curl_init$json_url );
 
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => $username ":" $password   // authentication
);
 
// Setting curl options
curl_setopt_array$ch$options );
 
$result =  curl_exec($ch); // Getting JSON result string

$cache_feedbin '/var/www/ffio.it/htdocs/'.sha1($json_url).'.json'

if(
file_exists($cache_feedbin) && filemtime($cache_feedbin) > time() - 1000){ 
// if a cache file newer than 1000 seconds exist, use it 
$data_feedbin file_get_contents($cache_feedbin); 
} else { 
$data_feedbin file_get_contents($result); 
file_put_contents($cache_feedbin$data_feedbin); 


foreach (
array_slice(json_decode($data_feedbin), 05) as $obj) { 
$feedbin_title $obj->title
$feedbin_url $obj->url
echo 
'<li><a href="'$feedbin_url'">'$feedbin_title'</a></li>'

?>


Why I'm getting "false" in the locally cached json? Is that json_encode wrong?

EDIT: Forgot to say it works perfectly if I don't try to load it from cache (so it's not something related to cURL or authentication).