Using the Yammer REST API I can include Open Graph (og) elements that will cause a graphic block to appear at the bottom of my generated post in Yammer:
$data = array(
'title' => $title,
'body' => $body,
'group_id' => $yammer_group_id,
'og_url' => $url_for_this_item,
'og_title' => $title,
'og_site_name' => 'Title of Our Site'
);
$json = json_encode($data);
$result = post_yammer($yammer_token, 'messages.json', $json);
When the graphic block is hovered over in Yammer, a strip of links appears at the bottom, one of which is "Share".
Is there any way to disable this functionality per-post (or overall for that matter) in Yammer - either the "Share" link specifically or the whole strip of links? My client has certain posts they'd like to make but discourage sharing.
I am guessing the answer is "no" - it's a pretty specific request and unlikely to be a common one - but figure someone might have an insight.
It's not possible to disable the links including Share from appearing in the Yammer user interface.
Related
I've been working on a project that needs to insert both text and other types of elements into a Google Docs Document, using PHP. I'm able to insert text using the following code:
$requests = [];
```
$requests[] = new \Google_Service_Docs_Request(
['insertText' => ['text' => 'Text to insert',
'location' => ['index' => $insertionIndex],
],
]);
```
$batchUpdateRequest = new \Google_Service_Docs_BatchUpdateDocumentRequest(['requests' => $requests]);
$docsService->documents->batchUpdate($documentID, $batchUpdateRequest);
I can also insert a page break with a similar call:
$requests = [];
```
$requests[] = new \Google_Service_Docs_Request(
['insertPageBreak' => ['location' => ['index' => $insertionIndex],
],
]);
```
$batchUpdateRequest = new \Google_Service_Docs_BatchUpdateDocumentRequest(['requests' => $requests]);
$docsService->documents->batchUpdate($documentID, $batchUpdateRequest);
Both of the above work fine (and as per Google's recommendations when I am carrying out multiple insertions I am working backwards). What I need to be able to do is add a horizontal rule to the document. I know Google Docs allows the manual insertion of them and Apps Script supports insertHorizontalRule but the Docs API doesn't seem to have an equivalent. I have searched here, Google, and the API documentation and can't find any reference to it. Could someone tell me if it is possible? If it is possible, what is the correct request type?
It's seems additionally strange that there isn't a documented way of inserting them, and yet you can query the contents of an existing document and any that are in the document are reported back to you as part of its structure.
For clarity of purpose, I am trying to append the contents of one Google Doc to the another. If anyone knows of a better way to do this than consuming the source document element by element and creating a request to add those elements to the destination document, that would bypass the need to handle inserting a horizontal rule.
You want to insert the horizontal rule to Google Document using Docs API.
You want to achieve this using php.
You have already been able to get and put the values for Google Document using Docs API.
I could understand like above. Unfortunately, in the current stage, it seems that there are no methods for adding the horizontal rule in Google Docs API yet, while "horizontalRule" can be retrieved by documents.get. Docs API is growing now. So this might be added in the future update.
So in the current stage, it is required to use the workaround for this.
Pattern 1:
In this pattern, the horizontal rule is added to Google Document using Web Apps created by Google Apps Script as an API.
Usage:
1. Set Web Apps Script:
Please copy and paste the following script to the script editor for Google Apps Script.
function doGet(e) {
DocumentApp.openById(e.parameter.id).getBody().insertHorizontalRule(Number(e.parameter.index) - 1);
return ContentService.createTextOutput("Done");
}
2. Deploy Web Apps:
On the script editor, Open a dialog box by "Publish" -> "Deploy as web app".
Select "Me" for "Execute the app as:".
Select "Anyone, even anonymous" for "Who has access to the app:".
This setting is for a test situation.
You can also access with the access token by setting "Only myself" instead of "Anyone, even anonymous".
Click "Deploy" button as new "Project version".
Automatically open a dialog box of "Authorization required".
Click "Review Permissions".
Select own account.
Click "Advanced" at "This app isn't verified".
Click "Go to ### project name ###(unsafe)"
Click "Allow" button.
Click "OK".
Copy the URL of Web Apps. It's like https://script.google.com/macros/s/###/exec.
When you modified the Google Apps Script, please redeploy as new version. By this, the modified script is reflected to Web Apps. Please be careful this.
3. Use Web Apps as an API:
The following script is for PHP. Please set the query parameter of id and index. id is the Google Document ID. When index=1 is set, the horizontal rule is inserted to the top of body in Document. In this case, index means each row in the Google Document.
$url = 'https://script.google.com/macros/s/###/exec?id=###&index=1';
$curl = curl_init();
$option = [
CURLOPT_URL => $url,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_FOLLOWLOCATION => true,
];
curl_setopt_array($curl, $option);
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
Pattern 2:
I think that your proposal of I'm also going to look at possible inserting a thin table with a top border line as a replacement for a horizontal rule. can be also used as the workaround. For achieving this, the script is as follows.
When this script is run, new table that has the line of only top is created to the top of document. Before you run the script, please set $documentId. In this case, please set Google_Service_Docs::DOCUMENTS to the scopes.
Sample script:
$documentId = '###';
$index = 1;
$style = [
'width' => ['magnitude' => 0, 'unit' => 'PT'],
'dashStyle' => 'SOLID',
'color' => ['color' => ['rgbColor' => ['blue' => 1, 'green' => 1, 'red' => 1]]]
];
$requests = [
new Google_Service_Docs_Request([
'insertTable' => [
'location' => ['index' => $index],
'columns' => 1,
'rows' => 1
]
]),
new Google_Service_Docs_Request([
'updateTableCellStyle' => [
'tableCellStyle' => [
'borderBottom' => $style,
'borderLeft' => $style,
'borderRight' => $style,
],
'tableStartLocation' => ['index' => $index + 1],
'fields' => 'borderBottom,borderLeft,borderRight'
]
])
];
$batchUpdateRequest = new Google_Service_Docs_BatchUpdateDocumentRequest([
'requests' => $requests
]);
$result = $service->documents->batchUpdate($documentId, $batchUpdateRequest);
References:
Web Apps
insertHorizontalRule()
Method: documents.batchUpdate
I am trying to get the number of downloads of an application that I have uploaded to Google Play.
I am searching for an API (or something similar) that retrieves to me the number of downloads with the authentification of the user. I do not want third party applications (like AppAnnie).
It would be great if it could be on PHP and I found that there is a library which I think it is the most closest API I could find to get data from Google applications.
Google APIs Client Library for PHP
but I cannot find any mention to Google Play applications.
Is there some way to get the downloads of an specific application having the authentification keys?
Thanks in advance!
Use the google-play-scraper library to get an app information as below:
Example:
$app = $scraper->getApp('com.mojang.minecraftpe');
Result:
array (
'id' => 'com.mojang.minecraftpe',
'url' => 'https://play.google.com/store/apps/details?id=com.mojang.minecraftpe',
'image' => 'https://lh3.googleusercontent.com/30koN0eGl-LHqvUZrCj9HT4qVPQdvN508p2wuhaWUnqKeCp6nrs9QW8v6IVGvGNauA=w300',
'title' => 'Minecraft: Pocket Edition',
'author' => 'Mojang',
'author_link' => 'https://play.google.com/store/apps/developer?id=Mojang',
'categories' => array (
'Arcade',
'Creativity',
),
'price' => '$6.99',
'screenshots' => array (
'https://lh3.googleusercontent.com/VkLE0e0EDuRID6jdTE97cC8BomcDReJtZOem9Jlb14jw9O7ytAGvE-2pLqvoSJ7w3IdK=h310',
'https://lh3.googleusercontent.com/28b1vxJQe916wOaSVB4CmcnDujk8M2SNaCwqtQ4cUS0wYKYn9kCYeqxX0uyI2X-nQv0=h310',
// [...]
),
'description' => 'Our latest free update includes the Nether and all its inhabitants[...]',
'description_html' => 'Our latest free update includes the Nether and all its inhabitants[...]',
'rating' => 4.4726405143737793,
'votes' => 1136962,
'last_updated' => 'October 22, 2015',
'size' => 'Varies with device',
'downloads' => '10,000,000 - 50,000,000',
'version' => 'Varies with device',
'supported_os' => 'Varies with device',
'content_rating' => 'Everyone 10+',
'whatsnew' => 'Build, explore and survive on the go with Minecraft: Pocket Edition[...]',
'video_link' => 'https://www.youtube.com/embed/D2Z9oKTzzrM?ps=play&vq=large&rel=0&autohide=1&showinfo=0&autoplay=1',
'video_image' => 'https://i.ytimg.com/vi/D2Z9oKTzzrM/hqdefault.jpg',
)
EDIT: Easily get downloads count as below:
echo $app['downloads']; // Outputs: '10,000,000 - 50,000,000'
Or if you want the left value:
$matches = null;
$returnValue = preg_match('/.*(?= -)/', '10,000,000 - 50,000,000', $matches);
echo $matches[0]; // Outputs: '10,000,000'
Or if you want the right value:
$matches = null;
$returnValue = preg_match('/(?<=- ).*/', '10,000,000 - 50,000,000', $matches);
echo $matches[0]; // Outputs: '50,000,000'
Then easily convert it to integer using:
$count = null;
$returnValue = (int)preg_replace('/,/', '', $matches[0], -1, $count);
echo $returnValue; // Outputs: 10000000 or 50000000
This is about meta data api. You can look at below.
https://developers.google.com/android-publisher/api-ref/reviews
You need to Scrape it. Generally speaking, & of course in this particular case, when the website(here: Google Play) does not provide an API to make your(client's) desired data accessible to him, Web scraping is one of the best methods to gather your required information.
Nearly every piece of information that you can see on a web page, can be scraped. Nowadays with great improvements of web scrapers, not only you are able to grab data from a target website, but also "crawling it like a user", "posting information to website via forms", "logging in as a user" & etc. has become a routine for any web scraper.
There are very strong scrapers out there, like Scrapy(likely the most reputed one, written in Python) almost for every language. AFAIK the best web scraper in PHP, is Goutte written by legendary #fabpot from FriendsOfPHP.
From the Data-Extraction POV, Goutte supports both "CSS Selectors" & XPath (Because it uses Symfony's DOM Crawler as Crawling engine). So you can crawl the document the way you want to extract every piece of information in any hidden corner of a web page!
You can go faraway in scraping with Goutte, But just as a tiny example for grabbing "number of installs" from an ordinary App page in a blink of an eye:
use Goutte\Client;
$Client = new Client();
/**
* #var \Symfony\Component\DomCrawler\Crawler
*/
$Crawler = $Client->request('GET', "https://play.google.com/store/apps/details?id=com.somago.brainoperator&hl=en");
$numberOfInstalls = $Crawler->filter('div.details-section-contents div.meta-info')->eq(1)->filter('div.content')->eq(0)->text();
echo $numberOfInstalls;
It will simply print Brain Operator game's "number of downloads".
This project https://github.com/ArcadiaConsulting/appstorestats is a API in Java to get statistics from Google Play and AppStore
checkout this library 42 matters gives number of downloads , rating many more
With AppID you can get it from the GooglePlay API
Or if the app is yours you can export the statistics from Google Cloud (reference)
In python you can use this.
from google_play_scraper import app #if not installed google_play_scraper then install by **pip install google-play-scraper**
playstore = app('test.example.com');
print(playstore):
I've developed an app in Laravel, using codebird-php, that's able to post tweets with images, videos and links. The code works as it's intended but I was told by my boss to hide the url in the final tweet and leave only the card, this for aesthetic purposes.
You can see what I'd like to do in the next pictures.
On top you can see a tweet from TechCrunch with a card but no url in body, this is wat I want to achieve.
However, I've also noted that there are tweets with cards and a visible url in the body. TechCrunch also as an example.
I've read into Twitter's API thinking the url might be an additional parameter as Facebook does, but I found nothing. I've also thought that it might be Twitter's site hiding the urls in web as in Twitter for Mac I can see the url.
I really don't know, I've been looking for a couple of days now and don't know what or how to do it. Does anyone know how to achieve that? Or am I right thinking that it's Twitter hiding the url in web?
Thank you all for your time.
EDIT:
Here's my code.
$sm = SocialScheduling::find($id);
$sm->update([
'persona_id' => $request->get('persona_id'),
'social_auth_id' => $request->get('social_auth_id'),
'social_scheduling_category_id' => $request->get('social_scheduling_category_id'),
'message' => $request->get('message'),
'post_link' => $request->get('post_link'),
'post_to_feed' => $request->get('ptf'),
'social_networks' => json_encode($request->get('social_networks')),
'facebook_pages' => json_encode($request->get('facebook_pages')),
'programmable_type' => $request->get('programmable_type'),
'programmable_id' => $request->get('programmable_id'),
'client_id' => $request->get('client_id'),
'image_url' => $request->get('image_url'),
'publish_time' => $request->get('publish_time')
]);
$sm->save();
$sm->load('persona','client','category','programmable','social_auth');
$persona = SocialAuth::find($sm->social_auth_id);
Codebird::setConsumerKey( Config::get('services.twitter.client_id'),
Config::get('services.twitter.client_secret'));
$tw = Codebird::getInstance();
$tw->setToken($persona->twitter_token,$persona->twitter_token_secret);
$data = [
'status' => $sm->message
];
$reply = $tw->statuses_update($data);
What my code does is it updates the SocialScheduling model, then it uses social_auth_id to find the model with the credentials and assigns it to $persona, afterwards I build the tweet adding the url to the tweet message, but I'd like to know if there's an additional parameter, like Facebook does, where I can send the url. I didn't see anything in Twitter's docs.
I'm a bit confused. I've read the docs and tutorials on the web for getting permission for "publish_action" so that the user can choose the option to automatically post a link on their FB feed when they create a new post on my site (instead of having to do it manually every time).
I set up the page to obtain the user permission for "publish_action" and created the parameters (as shown below). THis works great when I do it, but I am using my developer account. On the facebook developer group I was informed that we are not able to write the message, caption, or link description for the user.
Is this really the case? If so, how is that different than the share dialogue? What's the point in the publish_action permission? Is the publish_action deprecated?
$params = array(
"message" => "I just added a new post.",
"link" => $post_link,
"picture" => "http://example.com/fbpreview2.jpg",
"name" => "Name of website",
"caption" => "www.example.com"
, "description" => "This is a website"
);
$request = ( new FacebookRequest( $session, 'POST', '/me/feed', $params ) )->execute()
The Facebook Platform Policy's documentation on prefilling requires that the user have typed everything in the message parameter.
If you post only the contents of the user-generated post, you should be compliant with the rules. Adding anything to it that the user didn't explicitly type - additional copy, links, hashtags, etc. - is forbidden.
As an example, if I posted a blog post to a blogging system, you could provide a "post this to Facebook too" checkbox/button. Posting the blog entry's exact user-typed text would be OK, but posting a message like "I just blogged on example.com/post.html" would be forbidden.
/me/feed doesn't accept caption or description parameters, so it won't matter if you pre-fill them - they don't do anything.
When posting a custom story via the Graph API, is it possible to specify/change the caption of the attachment when I post the story to the user's account, i.e. on the fly?
Right now it defaults to the name of the app posting the action ("Action Center - Scale Review" in the screenshot).
I see in the docs for stories that I can specify up to 4 captions via the UI. But it's not clear to me when these take affect; for example, in the screenshot, I have 4 captions specified for that story - but none are showing. Plus, that's not on the fly/dynamic which is what I'm looking for.
It doesn't look like passing "caption" as an option when posting the action has any effect, nor does a "og:caption" param on the custom object.
I can specify the caption when posting a link via other methods - for example, when publishing a post on a users wall, I can specify the caption for the link.
I am not sure whether those “caption” fields are shown any more for simple objects (the docs might be outdated on this). Even if they are, you can not populate them dynamically, apart from using object property placeholders.
I think you best bet is to use the description (the “Heres a A Demo […]” line in your screenshot) to place the information you want to publish. You can create objects “on the fly” using the Object API. If you want individual objects on a “per user” basis, then this would be the way to go.
To make the captions dynamic you have to add curly braces : example :
by {}
When typed "{" it will show a drop down with your custom objects and you can use your objects to make captions dynamic.
However there is a huge limitation of bringing these captions into new lines.
It's clearly stated in the documentation link you provided.
Here's the code:
$request = new FacebookRequest(
$session,
'POST',
'/me/feed',
array (
'message' => 'This is a test message',
'link' => '',
'picture' => '',
'name' => '',
'caption' => '',
'description' => '',
)
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
When you click on the arrow next to "link" in the Facebook Docs page, you'll see the other options related to the "link".