accessing data in GET account/verify_credentials in twitter with php - php

When I use the method in the twitter API
$content = $connection->get('account/verify_credentials');
it returns a json that has all the data of the user
I know that I can access for example the Screen Name like this :
$content->screen_name
but how can I access Country and Country Code ...

You can access the users' location with the location field. You will have to guess the country (and its code) from this.
For further documentation, see the corresponding Twitter Developers page : https://dev.twitter.com/docs/platform-objects/users.

Related

Twitter oembed for timelines?

Hi I use the following code to embed tweets but I am wondering if there is away as simple as the following to embed user profiles, I can't seem to find it on dev.twitter.com they keep taking me to make a widget. which is what I want to do but I want them to do it on request of the PHP
Currently i use something like this. But as you can see from below it only gets the status and not the timeline of the user.
$status = file_get_contents("https://api.twitter.com/1/statuses/oembed.json?url=".$links[$j]);
$stats = json_decode($status);
//$string = "https://api.twitter.com/1/statuses/oembed.json?url=".$links[$j];
if(isset($stats->errors))
{
}
else
$string=str_replace($links[$j],''.$links[$j].'',$string).$stats->html;
}
You can't get the html of users timeline, like you are getting it for status.
There is no end point with oembed available for users profile.
But you can easily build it yourself by following these steps.
Register an application
Get the API keys and access token
Use some library for PHP from these listed in this page Twitter Libraries, I would prefer going with the abraham's library
Get the user details by making request to this URL:
https://api.twitter.com/1.1/users/show.json?screen_name=[screen_name]
*Note: Twitter API v1 is deprecated so use API v1.1 for making requests
Fetch the JSON response and render it in your html code

Get user info from google plus using php

How do I get user info like profile picture, location, description etc.
I have a field in form called google+ url. Now If any user filled it with their google+ url, I want to get their profile picture, location and description using their google+ url, Is it possible without creating google+ application?
A Google+ URL generally contains the Google+ ID for a user. You can parse out that ID, and then make a people.get API call using the ID. The response will only contain information that is publicly available on the user's profile, though. Also, if a user is verified, their URL will not contain their ID, but rather their verified name, but this will also work as an ID.
In PHP, the call looks like: $me = $plus->people->get('{{ID}}');
You can learn more about the people.get API call and see a full example at https://developers.google.com/+/api/latest/people/get.

get who likes facebook post by php code

i want to get who like facebook post then and store it in php variable ... then look for specific name i want
if it is about facebook photo i can use this
$url = 'graph.facebook.com/photoid'
and then i use the code
file_get_contents($url);
and then search about the name who liked the photo
but in post there is no graph to get who like post
i tried to put the whole link like
$url = 'https://www.facebook.com/AmrKhaled/posts/10152183719946165'
and then i use the code
file_get_contents($url);
but not found the name ... and if i var_dump($filegetcontent) and search my self no name is found
i need to know who like my post by php code ?? thanks
The problem is not the user agent because you shouldn't be scraping the page.
The id in that post is at the end
http://graph.facebook.com/10152183719946165
You just need a valid access token to retrieve it.
To read a Page you need:
an app or user access token for public and non-demographically restricted pages
a user access_token for restricted pages that the current user is able to view (no special permissions required)

Getting Facebook status messages of a page I own

Say I have a page on Facebook and updating its status and posting on its wall.
What I want is getting that data in json or xml format and use it on my own web page.
All the api docs I've read so far requires an access token, which I shouldn't need.
Twitter has a rest api like http://twitter.com/statuses/user_timeline/twitter_username.json?count=10, which returns the data in json format. I need something like that.
Almost all Facebook graph API calls require an access token, including the page feed you seek. You can get the feed in json format like: https://graph.facebook.com/pageIdOrName/feed or https://graph.facebook.com/pageIdOrName/statuses but you will need to append an access_token querystring parameter. You can test this with the Facebook Graph API explorer, and you could even use that access_token if you don't want to create an application.

How to search Twitter?

I need a PHP script that uses the Twitter API to obtain the following information: the number of unique tweets (or status updates) from a specific user (using their twitter username) containing a specific hashtag during a specific period of time.
I need that value to be the only returned data from calling that function/script; as well as the customizable lines of code containing all relevant values that I need to fill (app id, secret, username to obtain info from, etc).
Zend Framework has a nice Twitter API lib, which can be used standalone:
http://framework.zend.com/manual/en/zend.service.twitter.html
This is very simple to do with Twitter's Search API.
This is a JSON feed (just fetch with cURL or file_get_contents() and parse with json_decode()) of my Twitter posts that include the #fb hashtag: http://search.twitter.com/search.json?q=+%23fb+from%3Aceejayoz

Categories