I'm trying to figure this out all day...
With PHP SDK I can add a Facebook event to my Facebook page. But, if I try to set the wall picture of the events page, it isn't working. I found this:
/* make the API call */
$response = $facebook->api(
"/{event-id}/picture",
"POST",
array (
'source' => '{image-data}',
)
);
/* handle the result */
But the image-data has to be in multipart/form-data format. Does anyone know how to do this?
Also, I found that you could do this with a 'url' parameter instead of the 'source' parameter, but this isn't working either.
Maybe I've missed some permissions in my app settings?
Hope someone can help! Thanks!
I think you are talking of the event page's cover photo. You've used the method described in the official documentation to upload a cover photo of an event - but unfortunately this don't work as of now.
I've asked this before in the developers site, check here.
The only way to do this (as of now)-
\POST /{event-id} with param: cover_url
Code:
$param = array(
'cover_url' => '{image-link}'
);
$facebook->api('/{event-id}', 'POST', $param);
(image data wont work, you require a link to image)
Related
I'm trying to develop a Play Store reviews scraper in PHP and I need to make a POST request to this URL https://play.google.com/store/getreviews, and I saw the parameter post with firebug.
I am using Goutte library and here is my code:
require_once 'goutte.phar';
use Goutte\Client;
$client = new Client();
$params = Array(
"id" => "com.trello",
"pageNum" => 2 ,
"reviewSortOrder" => 2 ,
"reviewType" => 0,
"xhr" => 1
);
$crawler = $client->request('POST' , 'https://play.google.com/store/getreviews', $params);
The problem is that the request returns nothing. Is there anyone who already faced this problem and solved it?
I don't think this is possible. Google Play changed their review interface last year. They now have a "token" parameter which is missing here. I have worked before to try and work out what seeds this (see Google play review scraping changes) but I can't figure it out. After a number of attempts to hit that webservice with an incorrect request (presumably without the token) Google Play starts blocking your IP, that's why you'll be getting nothing back after a while (and won't be able to open Google Play in your browser either). If you find a solution, let me know!
This URL works for me, with the form-post data in your example.
https://play.google.com/store/getreviews?authuser=0
Using the events API I have the following code to post my event with an event photo
$facebook = new Facebook(array(
"appId" => "XXX",
"secret" => "XXX",
"cookie" => false,
"fileUpload" => true
));
$data = array("name"=>$eventTitle,
"start_time"=>$startTime,
"description"=>$description,
"privacy_type"=>$privacyType,
basename($fileName) => '#'.$fileName
);
$result = $facebook->api("/me/events","post",$data);
I'm interested in uploading a cover photo and I haven't found a clear way to do so with the PHP sdk. I've tried "source" => '#'.$coverPhoto, "cover" => '#'.$coverPhoto, "cover_url" => '#'.$coverPhoto and:
$data = array("name"=>$eventTitle,
"start_time"=>$startTime,
"description"=>$description,
"privacy_type"=>$privacyType,
basename($fileName) => '#'.$fileName,
"cover" => array(
"source" => '#'.$coverPhoto
)
);
But I can't seem to find the right way to push in a cover photo. Any ideas?
Unfortunately, you can't do it as of now.
There are two event related endpoints in Graph API: /{event-id} and /{user-id}/events and according to the Graph API documentation, none of them provide a support to upload the Event cover picture. Also, the documentation does not mention anything about support to upload the event photo (which, I assume, you were successfully able to do with your code).
However, based on the official Graph API documentation and my knowledge of Graph API, it's currently not possible to do that.
The method described in the official documentation to upload a cover photo of an event don't work as of now. I've reported this as a bug. You can subscribe to this bug to get any updates regarding the same.
The only way to do this (as of now)-
Firstly, you cant do this upload cover pic while creating an event. You first have to create an event, as a result you'll get the event_id. Use this event_id, to make a call:
\POST /{event-id} with param: cover_url
Code:
$param = array(
'cover_url' => '{image-link}'
);
$facebook->api('/{event-id}', 'POST', $param);
I am trying to render a SoundCloud HTML5 widget using the PHP API, but every time I run the command I think should return the HTML for the widget, I simply get an Exception:
The requested URL responded with HTTP code 302
I realise this is a redirect. What I don't know is why that's all I ever get, or what to do about it to actually get the widget HTML.
The documentation on the API says that to embed the widget using PHP you should do this:
<?php
require_once 'Services/Soundcloud.php';
// create a client object with your app credentials
$client = new Services_Soundcloud('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET');
// get a tracks oembed data
$track_url = 'http://soundcloud.com/forss/flickermood';
$embed_info = $client->get('/oembed', array('url' => $track_url));
// render the html for the player widget
print $embed_info['html'];
I'm running this:
// NB: Fully authorised SoundCloud API instance all working prior to this line
// $this->api refers to an authorised instance of Services_Soundcloud
try {
$widget = array_pop(
json_decode( $this->api->get('oembed', array('url' => $track_url)) )
);
print_r($widget);
} catch (Exception $e)
{
print_r($e->getMessage());
}
where "track_url" is actually the URL I get back when asking SoundCloud for a track object earlier in the app using the same API.
I'm not actually sure this URL is correct in the first place, because the track object I get back gives the 'uri' in the form:
[uri] => https://api.soundcloud.com/tracks/62556508
The documentation examples all have a straight http://soundcloud.com/username/track-permalink URL - but even using a known path to a public track the attempt to run the API oembed method fails... I still get a 302 Exception.
Finally, there are mentions of setting "allow_redirects" to false in the 'get' command, but this has no effect when I add to the parameters used to build the query to the API. I also tried adding additional cURL options, but that too had no effect.
I have definitely enabled API access to the track within SoundCloud.
Kind of banging my head off the wall on this. If anyone has any pointers I'd be very grateful to hear them. Just for clarity's sake, I am able to access all the user data, comments etc. via the API instance I have created, so it appears to be working fine.
Thanks for pointing this out. There was a bug in the documentation that lead you astray. Sorry about that. I've updated the docs to fix the bug. Here's the updated code sample:
<?php
require_once 'Services/Soundcloud.php';
// create a client object with your app credentials
$client = new Services_Soundcloud('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET');
$client->setCurlOptions(array(CURLOPT_FOLLOWLOCATION => 1));
// get a tracks oembed data
$track_url = 'http://soundcloud.com/forss/flickermood';
$embed_info = json_decode($client->get('oembed', array('url' => $track_url)));
// render the html for the player widget
print $embed_info->html;
Note the differences:
You need to set CURLOPT_FOLLOWLOCATION to 1 as mentioned in the comments above.
You need to wrap the return from $client->get in json_decode
The result is an stdClass object, not an Array and so the html property has to be accessed using the -> operator.
Hope that helps. Feel free to comment in case you're still having problems and I'll amend my answer.
I currently am able to post to a users wall however I would like the post to give a preview since what im posting is a link...
To explain myself better If i was to log into my facebook account and copy a link and paste it to my wall it displays an audio player (all the meta data is already configured, tested and working) however, using code to post this same link it doesnt show the audio player instead it only shows the link to click on. Is there a way i can make facebook display the audio player...?
Heres the code im using to post:
$fbResult = $facebook->api(
'/' . $userId . '/feed/',
'post',
array('access_token' => $access_token, 'message' => $url)
);
Thanks in advance for the help!
I’m assuming you’re posting the URL as part of your message parameter?
Do it by explicitly using the link parameter for the URL.
https://developers.facebook.com/docs/reference/api/user/#links
I am using the main soundcloud wrapper (https://github.com/mptre/php-soundcloud) to try and pull the tracks off my account onto my website. I had the whole thing working great but just by accessing a query (my username has changed and isn't as unique, so i need to change the query). So what I need to request is exactly this "https://api.soundcloud.com/users/isound604/tracks.json" and if you check in the API console you will see it returns my tracks.
My problem is that i don't know how to make this request with the wrapper. I used to use:
$string = $soundcloud->get('tracks', array('q' => 'beatmanshan', 'order' => 'created_at'));
but the new request doesn't seem to work in that function. Can anybody shed any light on this issue? Please and thank you in advance! Let me know if you need any more info.
Have you already authenticated ok using the api? To check
$my_details = json_decode($soundcloud->get('me'));
Should return your account details
If so have you tried
$string = $soundcloud->get('users/isound604/tracks', array('order' => 'created_at'));