I'm a bit new to using the Facebook API and I'm currently trying to query the API for the user's profile picture. I am using this access-token return to get the user information when he/she logs in:
//Next get the user id of the current user, which is unique and will be used in the database
$response = file_get_contents("https://graph.facebook.com/me?fields=id,name,picture&access_token=$accessToken");
$data = json_decode($response);
print_r($data);
This print_r outputs:
stdClass Object ( [
id] => 0000000000000000
[name] => Username
[picture] => stdClass Object (
[data] => stdClass Object (
[is_silhouette] => [url] => valid_url )
)
)
However, the picture is low-resolution and also 50x50. How can I get a higher quality image and a higher dimension? I couldn't find any information in the API. I read the API (which added to my confusion), and it first asked me to add a redirect=false in my query (it was using an HTTP GET method)
I can specify it correctly in the http_get method
Fetch image based on Facebook id of user and you can get every size of image like below example :
Large : https://graph.facebook.com/{facebookId}/picture?type=large
You can change type based on your requirement here is the some type normal,small,square.
You can also use custom width and height for get any size profile picture by link http://graph.facebook.com/{facebook-user-id}/picture?width=1000&height=1000
and for type parameter you can use {small, normal, album, large, square}
Related
As you can see in the image below, I have 1 subscription active in my Stripe Test environment.
But when I try to retrieve this subscription through the endpoint GET /v1/subscriptions it comes empty.
https://stripe.com/docs/api/subscriptions
$stripe = new \Stripe\StripeClient(env('STRIPE_SECRET'));
$list = $stripe->subscriptions->all();
print_r($list);
The result:
Stripe\Collection Object
(
[object] => list
[data] => Array
(
)
[has_more] =>
[url] => /v1/subscriptions
)
I have double checked and I'm using the test keys.
Also, if I try to retrieve the single subscription using the endpoint GET /v1/subscriptions/:id:
$stripe->subscriptions->retrieve('sub_....', []);
It returns the error:
No such subscription 'sub_.....'
And the ID is totally correct (just copied and paste from Stripe dashboard).
If you cannot retrieve the subscription directly by ID, you are likely mixing up keys from a different account. Double check the account you're logged in to and which account the keys belong to and try again.
i want to post content to wordpress from other php app. i am using rest api plugin for posting and for authentication i am using oath plugin.i just want to know how to get the access token .i am referring
https://github.com/WebDevStudios/WDS-WP-JSON-API-Connect
for the json_url in the code i use
eg(http://myproject.info/wpsingle/wp-content/plugins/my_plugin/json-rest-api/lib/wp-json.php)
ends up in error.
[errors] => Array ( [wp_json_api_connection_failed_error] => Array (
[0] => There was a problem connecting to the API URL specified. ) )
[error_data] => Array ( )
I used this for the same thing. I used basic authentication. i.e. admin panel username and password for authentication. Because I was the only person who was going to post to wordpress. And the correct URL to access end point was like below
http://domain.com/wp-json/posts?filter[s]=awesome
this is the link to how to create a post. I used Guzzle to call api like below to get a posts from particular category.
$client = new \GuzzleHttp\Client();
$response = $client->get("http://domain.com/wp-json/posts?filter[category_name]=test", array('auth' => ['username','password']));
$posts = $response->json();
But, If you are going to let other people post than you must use OAuth. Because you can not share admin panel username and password with everyone.
The documentation for posting a link to a Facebook page has me stumped at this point:
picture Determines the preview image associated with the link. string
I've tried passing a valid URL and a base_64 encoded image, to no avail. Passing a URL results in the link posting without the image, but without returning any errors. This is what I'm passing in that case, as printed by PHP's print_r():
Array
(
[link] => http://mysite.cl/etc.etc.html
[name] => test name
[description] => test description
[caption] => test caption
[access_token] => [my_access_token]
[picture] => http://mysite.cl/app/site/artic/20140909/imag/foto_0000000120140909171931.jpg
)
Passing a base_64 encoded image results in an API error:
(#100) picture URL is not properly formatted
What should be the content of the picture field?
After checking some more, I've gathered that posting a complete URL like I am doing is right, but there's an open bug with facebook's safe_image script, the script that caches posted media, and it results in a 1x1px picture. Other questions in the same vein in SO include this one.
I also try get data from getSignedRequest() (PHP-SDK 3.4) but page data is empty in response:
Array
(
[algorithm] => HMAC-SHA256
[code] => AQC94XuRCkLCYkJkBU2j2JvR_H0dEesyyWE9IOnBorRExZyjDhRR1M5JnG5CiWLf12xuO0CiFzVva05D-L3NNuId-IbOg4VO8X-DENRlbj3CiSIzBn....
[issued_at] => 1408109031
[user_id] => 6660247934796
)
The 'liked' property will no longer be returned in the 'signed_request' object for Page Tab apps created after today.
https://developers.facebook.com/docs/apps/changelog
See v2.1 updates, Fangates are not possible anymore, and not allowed according to the platform policy of Facebook.
How can I retrieve a specific post/discussion from a open group through LinkedIn API using PHP.
I was trying with the following API request as shown in here http://developer.linkedin.com/documents/groups-api#post :
https://api.linkedin.com/v1/posts/5835685921059532803:(id,type,category,creator,title,summary,creation-timestamp,relation-to-viewer:(is-following,is-liked,available-actions),likes,comments,attachment,site-group-post-url)
But this returns the following error:
Array
(
[status_code] => 400
[data] => stdClass Object
(
[errorCode] => 0
[message] => Invalid Post.id String {5835685921059532803}
[requestId] => XW2XMPBNKY
[status] => 400
[timestamp] => 1391441328953
)
)
Now, what's the error I have made with this request? What should I do to get a specific discussion?
Thanks.
I just solved the problem. The problem was while making the request. The discussion id (5835685921059532803) I was sending with URL was in wrong format. It should be like: g-GROUP_ID-S-DISCUSSION/POST_ID, for example: g-24405-S-5835685921059532803.
So the URL should be:
https://api.linkedin.com/v1/posts/g-24405-S-5835685921059532803:(id,type,category,creator,title,summary,creation-timestamp,relation-to-viewer:(is-following,is-liked,available-actions),likes,comments,attachment,site-group-post-url)
Hope this would save someone's valuable time.
You need An Api key and Secret key,to get an AUTHORIZATION_CODE,using that AUTHORIZATION_CODE,you will get an Access Token,and with that Access Token if you hit the url,then you will get the proper data,
details http://developer.linkedin.com/documents/authentication