manix Posted August 12, 2011 Share Posted August 12, 2011 Okay this is the first time I'm doing this and I don't really know where to start at, Basically I need all the information from this link: https://graph.facebook.com/manixchy to be returned in an array like $facebook["id"] = 100001240111056 $facebook["name"] = "Manix Hmr" and so on for the rest of the information.. Is that like possible? Quote Link to comment https://forums.phpfreaks.com/topic/244602-link-to-array/ Share on other sites More sharing options...
JasonLewis Posted August 12, 2011 Share Posted August 12, 2011 You'd need to use a combination of cURL and json_decode() to convert the stored object into a PHP-friendly object or array. Quote Link to comment https://forums.phpfreaks.com/topic/244602-link-to-array/#findComment-1256356 Share on other sites More sharing options...
manix Posted August 12, 2011 Author Share Posted August 12, 2011 Erm okay, that seems pretty logical but there's a problem, neither on my localhost nor on the shared hosting where my site is actually being hosted curl is enabled, is there any other way to retrieve a link's information else than curl? Quote Link to comment https://forums.phpfreaks.com/topic/244602-link-to-array/#findComment-1256364 Share on other sites More sharing options...
JasonLewis Posted August 12, 2011 Share Posted August 12, 2011 You might try to use file_get_contents, not sure if it will work or not. Make sure you read the notice at the bottom of that manual entry about fopen wrappers. Quote Link to comment https://forums.phpfreaks.com/topic/244602-link-to-array/#findComment-1256370 Share on other sites More sharing options...
manix Posted August 12, 2011 Author Share Posted August 12, 2011 I managed to somehow retrieve it lol, here's the code and it works brilliant $URL = "http://graph.facebook.com/manixchy"; $handle = fopen ($URL, "r"); $key = str_replace(' ', '%20',fread($handle, 1000000)); $key = json_decode($key, true); var_dump ( $key ); Thanks JaySonic Quote Link to comment https://forums.phpfreaks.com/topic/244602-link-to-array/#findComment-1256381 Share on other sites More sharing options...
Acoon Posted August 12, 2011 Share Posted August 12, 2011 $data = file_get_contents('https://graph.facebook.com/manixchy'); $facebook = json_decode($data,TRUE); print_r($facebook) Quote Link to comment https://forums.phpfreaks.com/topic/244602-link-to-array/#findComment-1256382 Share on other sites More sharing options...
manix Posted August 12, 2011 Author Share Posted August 12, 2011 quite shorter, guess I'll use that! Thank you Quote Link to comment https://forums.phpfreaks.com/topic/244602-link-to-array/#findComment-1256391 Share on other sites More sharing options...
manix Posted August 12, 2011 Author Share Posted August 12, 2011 There's a problem.. neither fopen nor file_get_contents manage to open a file using secure connection "https", and if I use unsecured one then facebook API says I need to use a secure connection... Really stuck this time, how do I open "https://graph.facebook.com/272908049391413/feed?access_token=somesuperlongcode" ? Quote Link to comment https://forums.phpfreaks.com/topic/244602-link-to-array/#findComment-1256569 Share on other sites More sharing options...
JasonLewis Posted August 13, 2011 Share Posted August 13, 2011 More than likely you're going to need to take advantage of cURL to grab the data off the page. Perhaps ask your host to enable it for you? Quote Link to comment https://forums.phpfreaks.com/topic/244602-link-to-array/#findComment-1256684 Share on other sites More sharing options...
jcbones Posted August 13, 2011 Share Posted August 13, 2011 file_get_contents() can use ssl connection. You can pass that in through the 3rd argument. http://www.php.net/manual/en/function.file-get-contents.php It will take a bit of reading for you to get it in there though. You will also have to provide a file location of your certificate. As well as use other functions. http://www.php.net/manual/en/function.stream-context-create.php http://www.php.net/manual/en/context.ssl.php Quote Link to comment https://forums.phpfreaks.com/topic/244602-link-to-array/#findComment-1256691 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.