I try to make an script to get data from LINKEDIN, i am able to get many of information about profile like name, mail, phone, picture url and so on, unfortunately how ever I try I can't get to informations like work experience and many other.
My Request looks like:
$xml_response = $linkedin->getProfile("~:(id,first-name,last-name,interests,publications,patents,languages,skills,date-of-birth,email-address,phone-numbers,im-accounts,main-address,twitter-accounts,headline,picture-url,public-profile-url)");
This work correctly, but lets try to add companies
Error:
I added it at the end of $linkedin->getProfile and here is the
error message what I get:
[message] => Unknown field {companies} in resource {Person}
Full function looks like:
public function linkedinGetUserInfo( $requestToken='', $oauthVerifier='', $accessToken=''){
include_once 'linkedinoAuth.php';
$linkedin = new LinkedIn($this->config['linkedin_access'], $this->config['linkedin_secret']);
$linkedin->request_token = unserialize($requestToken); //as data is passed here serialized form
$linkedin->oauth_verifier = $oauthVerifier;
$linkedin->access_token = unserialize($accessToken);
try{
$xml_response = $linkedin->getProfile("~:(id,first-name,last-name,interests,publications,patents,languages,skills,date-of-birth,email-address,phone-numbers,im-accounts,main-address,twitter-accounts,headline,picture-url,public-profile-url,educations,companies)");
}
catch (Exception $o){
print_r($o);
}
return $xml_response;
}
Documentation I found (but didn't help me )
https://developer.linkedin.com/docs/fields
I expect I miss something really stupid but cant figurate it out, can somone help me?
LinkedIn provided all these fields before May 12th 2015.
https://api.linkedin.com/v1/people/~:(id,first-name,last-name,email-address,picture-url,industry,associations,interests,num-recommenders,date-of-birth,honors-awards,three-current-positions,three-past-positions,volunteer,location," +
"positions:(id,title,summary,start-date,end-date,is-current,company:(id,name,type,size,industry,ticker))," +
"educations:(id,school-name,field-of-study,start-date,end-date,degree,activities,notes)," +
"publications:(id,title,publisher:(name),authors:(id,name),date,url,summary),"+
"languages:(id,language:(name),proficiency:(level,name)),"+
"skills:(id,skill:(name)))";
"courses:(id,name,number),"+
"recommendations-received:(id,recommendation-type,recommendation-text,recommender))";
"patents:(id,title,summary,number,status:(id,name),office:(name),inventors:(id,name),date,url))";
But, they have updated their APIs link:https://developer.linkedin.com/support/developer-program-transition
According to which only these
Profile API — /v1/people/~
Share API — /v1/people/~/shares
Companies API — /v1/companies/{id}
endpoints will be active, Rest require a Apply with Linkedin /Partner with Linked association.
phone-numbers,im-accounts,main-address,twitter-accounts,headline would come under r_contactinfo which needs a Apply with linkedin
Instead of companies, you must use positions keyword.
$xml_response = $linkedin->getProfile("~:(id,first-name,last-name,positions)");
Positions field description in the following address.
https://developer.linkedin.com/docs/fields/positions
Related
I am building a PHP script based on Facebook Marketing API,
The API system works fine,
I can get the result for the campaigns, the ads, and full insights as well.
But, I want to get the result of the leads.
Note (1): I got admin access to the APP, the Ad account, and the page as well,
Note (2): App Status: In Development
Note (3) : I send the API request for "leads_retrieval" and "leads_retrieval",
$permissions = ['email','public_profile','leads_retrieval','ads_management', 'ads_read', 'business_management', 'read_audience_network_insights', 'read_insights', 'manage_pages', 'pages_show_list', 'pages_manage_cta','pages_manage_instant_articles', 'publish_pages', 'read_page_mailboxes'];
My Code to get the lead result :
$ad = new Ad('<AD_ID>');
$leads = $ad->getLeads();
$lead = $leads->getResponse()->getBody();
print_r($lead);
Result:
{"data":[]}
So for some reason, I still get the incorrect empty result for the leads!
Any idea about how to get the correct lead result for the Ad?
Reference : https://developers.facebook.com/docs/marketing-api/guides/lead-ads/retrieving/v2.9
I have same problem before but I found that I'm using incorrect ad_id.
double check you ad id, its possible that your not getting the full list of ad id inside adset.
use $ads->fetchAfter() to get the next page of ads
check complete code here https://stackoverflow.com/a/56500241/2588592
I have problem with posting offer to page (which I am admin) via facebook api. It'is work, when I post feed to this page, but not for offers. This always return me FacebookSDKException with message : Invalid parameter. I use PHP (Laravel framework), but I think it does not matter on the language I use. I use this code:
try {
$response = $fb->post('/' . $page_id . '/offers' , $offerData, (string) $request->access_token
);
} catch (\Facebook\Exceptions\FacebookSDKException $e) {
return response()->json(['error'=>$e->getMessage(),
], 200);
}
where my "$request->access_token" is page access token. And in my "$offerData" I have this fields:
$offerData =[
'claim_limit'=>8,
'expiration_time'=>\Carbon\Carbon::now()->addDays(10)->toDateTimeString(),
'message'=>"bbb",
'title'=>"ascvc",
'coupon_required'=>false,
'image_url'=>'...',
'published'=>true,
'reminder_time'=>\Carbon\Carbon::now()->addDays(5)->toDateTimeString(),
// 'scheduled_publish_time'=>5
];
I also try do this by curl (not by first code) and by curl it returns similar error message.
"{"error":{"message":"Invalid parameter","type":"OAuthException","code":100,"error_subcode":1528104,"is_transient":false,"error_user_title":"Check Your Admin Permission Level","error_user_msg":"Only some admins of your Page are able to create and edit offers. Talk to the person responsible for your Page about your admin permission level.","fbtrace_id":"..."}}"
It looks that there is problem with permissions but at login to facebook I set this permissions:
['manage_pages', 'pages_show_list', 'email',
'user_hometown', 'publish_actions', 'user_photos', 'publish_pages']
I have no idea where is problem. I must to tell you that feeds on same page works fine, but not offers. Can you help me, please?
Take a look at the newer /nativeoffers endpoint; that should be a cleaner path through this one.
https://developers.facebook.com/ads/blog/post/2016/08/30/offer-ads-apis/
I just found out that Facebook updated their graph api and now require an access token to retrieve like counts for a page to be displayed on an external website. I went through the motions of setting up an app to get the token and have the following:
$fbData = json_decode(file_get_contents('https://graph.facebook.com/myFacebookName?access_toke=MyAppId|MySecretToken'));
print_r($fbData);
It seems to only be returning objects:
stdClass Object ( [name] => My Facebook Name [id] => id number )
And that is all, giving me nothing to parse through. The name and id coming through are correct so there is a connection happening. Note that I have edited out some information so MyFacebookName and MyAppId|MySecretToken are actually populated with the correct info. Any ideas how to get the full JSON list to grab page likes? Am I missing something?
UPDATE
Thanks to Tobi and further reading the graph api, documentation I was able to get the number of likes with with following:
$fbData = json_decode(file_get_contents('https://graph.facebook.com/name?fields=likes&access_token=appId|accessToken'));
<?php echo number_format($fbData->likes);?>
You need to specifically request the fields you want in the response. In your case this would be
https://graph.facebook.com/myFacebookName?fields=id,name,likes&access_toke=MyAppId|MySecretToken
I don't understand why you say there "nothing to parse", because the object IS returned and can be used. So what's the problem?
Using echo $fbData['likes'] should give you the number of likes.
See
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.4#fields
https://developers.facebook.com/docs/graph-api/reference/page#Reading
I need a way to display videos from a specific channel on a page using PHP.
I have authenticated my app and I can use some methods using the advanced API. I am using the official vimeo PHP library to connect.
Below is what I am trying to do and when I dump the array I do not get anything. I can get info back from using get videos from the entire account method.
require_once('/url/vimeo/vimeo.php');
$vimeo = new phpVimeo('number', 'number');
$vimeo->setToken('number','numbers');
$videos = $vimeo->call('vimeo.channels.getVideos', array('ACCOUNT' => 'NAME'));
If I put the channel name where ACCOUNT is I will get an invalid signature error.
Is it worth using something like simple HTML parser for PHP and doing it that or worth sticking with the advanced API?
I would highly advise using the advanced api. If you parse the html, it will break any time vimeo changes their channel pages. Additionally, channels have more than one layout
eg: vimeohq and nicetype
The second parameter of the "call" function should be any querystring parameters the api method requires.
In the case of "vimeo.channels.getVideos" you can provide
channel_id
user_id
page
per_page
summary_response
full_response.
To experiment with the getVideos method, you can use the playground.
So in the end, I believe you want the function to look like this..
$videos = $vimeo->call('vimeo.channels.getVideos', array('channel_id' => 'NAME'));
where NAME is either the channel id, or the channel name (the channel name matches the url slug, so for example "nicetype" not "nice type"
I am trying to tag a friend in FB message to be posted, I am using PHP, and for FB I am using FB Auth API 2.0, I have tried to get related information from facebook developers forum, however can't find enough information for this one.
Can anyone suggest me from where to get started for this? any links to related documentation or forum links using which I can get started?
You use the message_tags field of the Post object. Check out the docs:
message_tags: object containing fields whose names are the indexes to
where objects are mentioned in the message field; each field in turn
is an array containing an object with id, name, offset, and length
fields, where length is the length, within the message field, of the
object mentioned
Something like this:
$facebook->setFileUploadSupport(true);
$tags = array(
‘tag_text’ => ‘ak Yip’,
‘tag_uid’ => 642536423,//it’s my id on facebook as a sample
‘x’ => 10,
‘y’ => 10,
);
$args['tags'] = array($tags);
$args['image'] = ‘#’ . realpath($fn);
$data = $facebook->api(‘/me/photos’, ‘post’, $args);
Note:
**One:Your app need to get permissions like ‘user_photo_video_tags’ and ‘friends_photo_video_tags’.
Two:X,Y is proportion, not coordinate. Don’t put value over 100.**