Пример #1
0
 public function feed_publishStoryToUser($title, $body, $image_1, $image_1_link, $image_2, $image_2_link, $image_3, $image_3_link, $image_4, $image_4_link)
 {
     if (!is_platform_app_installed_to_feed($this->app_id, $this->user_id)) {
         return array(false);
     }
     $error = '';
     $feed_story = application_create_feed_story($this->app_id, $this->user_id, false, $title, $body, $image_1, $image_1_link, $image_2, $image_2_link, $image_3, $image_3_link, $image_4, $image_4_link, $error);
     if (!$feed_story) {
         switch ($error) {
             case 'error_title_link':
                 $this->throw_code(api10_FacebookApiErrorCode::API_EC_EDIT_FEED_TITLE_LINK);
                 break;
             case 'error_title_length':
                 $this->throw_code(api10_FacebookApiErrorCode::API_EC_EDIT_FEED_TITLE_LENGTH);
                 break;
             case 'error_title_name':
                 $this->throw_code(api10_FacebookApiErrorCode::API_EC_EDIT_FEED_TITLE_NAME);
                 break;
             case 'error_title_blank':
                 $this->throw_code(api10_FacebookApiErrorCode::API_EC_EDIT_FEED_TITLE_BLANK);
                 break;
             case 'error_body_length':
                 $this->throw_code(api10_FacebookApiErrorCode::API_EC_EDIT_FEED_BODY_LENGTH);
                 break;
             case 'error_photo_src':
                 $this->throw_code(api10_FacebookApiErrorCode::API_EC_EDIT_FEED_PHOTO_SRC);
                 break;
             case 'error_photo_link':
                 $this->throw_code(api10_FacebookApiErrorCode::API_EC_EDIT_FEED_PHOTO_LINK);
                 break;
             case 'error_illegal_content':
                 throw new api10_FacebookApiException(array('error_code' => api10_FacebookApiErrorCode::API_EC_PARAM, 'error_msg' => 'Your feed story contains illegal or malformed content.'));
             default:
                 $this->throw_code(api10_FacebookApiErrorCode::API_EC_EDIT_MARKUP);
                 break;
         }
     }
     $app_info = application_get_info($this->app_id);
     if (application_is_owner($this->app_id, $this->user_id)) {
         // Bypass checks if the developer is publishing to his own profile
         $publish = true;
     } else {
         // Get the number of available feed points and check call limits
         $available_feed_points = application_get_available_feed_points($this->app_id, $this->user_id);
         if ($available_feed_points == 0) {
             $this->throw_code(api10_FacebookApiErrorCode::API_EC_EDIT_FEED_TOO_MANY_USER_CALLS);
         }
         // Figure out how many feed points to use, and probabilistically determine whether or not to publish
         $publish = application_use_feed_points($this->app_id, $this->user_id, 1);
     }
     if ($publish) {
         application_publish_story_to_user($this->app_id, $this->user_id, $feed_story);
     }
     return array(true);
 }
Пример #2
0
function application_update($app_id, $app_profile, $user_id)
{
    global $data_conn;
    if (!application_is_owner($app_id, $user_id)) {
        return false;
    }
    // Ensure application_id does not drift away from original id
    if (isset($app_profile['application_id']) && $app_id != $app_profile['application_id']) {
        error_log("Error: Cannot change value of application_id in application_update.");
        return false;
    }
    $sql_set_terms = array();
    $editable_fields = get_editable_app_fields();
    foreach ($app_profile as $name => $val) {
        if (isset($editable_fields[$name])) {
            $sql_set_terms[] = "`{$name}`=" . (is_int($val) ? "%d" : "%s");
            $params[] = $val;
        }
    }
    $params[] = $app_id;
    if (!empty($sql_set_terms)) {
        $sql = 'UPDATE application SET ' . implode(",", $sql_set_terms) . ' WHERE application_id=%d';
        if (!vqueryf($data_conn, $sql, $params)) {
            error_log('PLATFORM: unable to update application profile on db');
            return false;
        }
    }
    return true;
}