Hey guys,
feel stupid for asking this question but I'm stuck and new with getting values from JSON.
In the JSON example of the statuses/mentions of the Twitter API: http://dev.twitter.com/doc/get/statuses/mentions
I'm trying to get the 'screen_name' value from with the 'user' directory/array piece (don't know the term). Heres what I'm using to pull values currently:
$lastmentions = $oauth->get('http://api.twitter.com/1/statuses/mentions.json');
$lastmentionsuser = $lastmentions[0]->user;
Thanks guys, Dex
This should work:
$screen_name = $lastmentionsuser->screen_name;
Woop Woop figured it!
It was:
$lastmmentionsuser = $lastmmentions[$i]->user->screen_name;
Related
Good morning all,
I have been stuck on a piece of code for a while and decided to ask one of you and create an account on Stackoverflow. I hope you guys can help!
See image
Image 2, output on web
I need to read out the [exportResult] but I cannot get there. I can read it now as;
$administration = array('demo', '');
$soapclient = new SoapClient("https://www.cashweb.nl/?api/3.0/wsdl");
$theCall = $soapclient->export('', '','','','', $administration, '0');
var_dump($theCall); // all result
var_dump($theCall['exportResult'] // XML result
So, i tried to use:
$theCall['exportresult']['R0101'][0]['F0101'];
But that is not working. Can anyone help me out how I can read the F0101 tag?
I don't know I'm sounding stupid or not?
I am trying to find the username of a person in facebook through php. Is that at all possible??
Any help would be appreciated.. Thanks
Username is not available in API v2.0 and later. So no it is not possible get the username from a user id or the opposite.
Sorry I don't have enough rep to post it as comment.
#A'aqu the $request_url must be https instead of http and it should be more like https://graph.facebook.com/yourUID?access_token=yourAccessToken rather than just http://graph.facebook.com/yourUID.
Please update your answer
what data you have?
if you have uid you can find by:
http://graph.facebook.com/yourUID
example
http://graph.facebook.com/1503382632
if you want put to php you can get
<?php
$request_url ="http://graph.facebook.com/1503382632";
$requests = file_get_contents($request_url);
$fb_user = json_decode($requests);
echo $fb_user->username; //this will outpun username
?>
I'm curious to use the facebook graph API as I don't like the simple like button with number of likes next to it. However I'm finding their documentation a bit confusing. I want to do this via PHP so I'm assuming I need the PHP SDK, is that right?
I'm looking at this page Graph API: Page however I don't understand how I would call the likes.
I'm not asking for someone to code this for me, just a little help in the right direction to understand how it works :)
Try this:
$json = #file_get_contents("http://graph.facebook.com/yourpage");
$json1 = json_decode($json,true);
$likes = $json1['likes'];
echo $likes;
This is pretty straightforward. Using the ID or the username of the page, access that
node via the Graph API:
PAGE_ID?fields=likes
In PHP would be something like:
$token_string = file_get_contents('https://graph.facebook.com/oauth/access_token?client_id='.$appID.'&client_secret='.$app_secret.'&grant_type=client_credentials');
$likes_response = file_get_contents('https://graph.facebook.com/PAGE_ID?fields=likes&'.$token_string);
$likes_obj = json_decode($likes_response);
$likes = $likes_obj->likes;
echo 'Likes count for page: ' . $likes;
Im trying to use the following PHP to add a favorite to my account:
$favorite = $connection->post('favorites/create/'.$id);
where $id is the status id but favorite don't return nothing also I'm trying with statuses/retweet/ but is the same
Also when you are debugging, use print_r($favorite); to help you. Saved me with my problem today actually :-) But Andre is correct, remove the fullstop.
Replace the period with a comma, right before $id:
$favorite = $connection->get('favorites/create',$id);
I am trying to fetch friend list. I wrote following code..
$friends = $this->facebook->api('me/friends');
echo count($friends);
Answer was 1. (though it should have been 456). What am I doing wrong? Thanks for help.
The data structure returned by the API is different than you think.
Try echo count($friends['data']); instead.